Problem scenario
You want to install Composer (a dependency manager for PHP) on your Debian/Ubuntu Linux server. What do you do?
Solution
- Run these commands:
sudo apt -y update
sudo apt -y install php-cli unzip
cd ~
sudo curl -sS https://getcomposer.org/installer -o composer-setup.php
HASH=curl -sS https://composer.github.io/installer.sig
echo $HASH
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- The last command above should have printed out "Installer verified". Now run these two commands:
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
composer
- You are done. The above directions were adapted from this external page.
- The above directions were tested to work on Debian 10.