DEV Community

Cover image for How to Install Composer on Linux - Debian
Philip Mac
Philip Mac

Posted on

How to Install Composer on Linux - Debian

To install Composer on Ubuntu, you can follow these steps:

Update the package list on your system:

sudo apt update
Enter fullscreen mode Exit fullscreen mode

Install some required packages using the following command:

sudo apt install curl php-cli php-mbstring git unzip
Enter fullscreen mode Exit fullscreen mode

Download the Composer installer using the following command:

curl -sS https://getcomposer.org/installer -o composer-setup.php
Enter fullscreen mode Exit fullscreen mode

Verify the downloaded installer:

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;"
Enter fullscreen mode Exit fullscreen mode

You should see the message "Installer verified" if everything is okay.

Run the installer:

sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Enter fullscreen mode Exit fullscreen mode

Verify the installation:

composer
Enter fullscreen mode Exit fullscreen mode

You should see the Composer version number and usage instructions.

That's it!Congratulation, You have successfully installed Composer on Linux - Debian.

Top comments (0)