Ubuntu - Install PHP and Composer

[1] Update Ubuntu

sudo apt update

[2] Install PHP CLI

sudo apt install php-cli unzip

[3] Install Composer

Change directory to home.

Install Composer

cd ~
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php

Using curl, fetch the latest signature and store it in a shell variable:

HASH=`curl -sS https://composer.github.io/installer.sig`

Verify that the installation script is safe to run:

php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"


Download and install Composer as a system-wide command named composer, under /usr/local/bin:

sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer