Dedicated Server, Magento, PHP Configuration, Uncategorized, VPS (Virtual Private Servers), WEB HOSTING

How to Install Composer on Linux

One of the package managers for PHP is called “Composer”, and is actually very popular since platforms like Magento uses it.  In this article, we will learn how to install and setup composer tool on Linux distributions.

And if you want to know more about Composer, as mentioned earlier, it is a package manager for PHP. It basically checks which other packages (dependencies) that are required by the project and facilitates you to install and update them. It is similar to the npm that the node has. You may learn more bout Composer on the official website here.

Now let’s get started with the steps for installing the popular dependencies manager for PHP on Linux.

CAUTION: Always be careful when you are running commands on a server because severe and irreversible damages can happen to the server if you make a mistake. It is also advisable to always take a backup or snapshot of the server before proceeding.

Installing Composer on Linux

Before installing the Composer, you must have PHP installed on your system. PHP is easy to install, just use the installation command for your distribution.

Installing PHP on Ubuntu/Debian and their derivatives.

NOTE: The Dollar sign represents the one that shows right before where any shell commands you type appear. So the Dollar sign is just to say that what comes after it is the command line you should execute. Therefore, do not add the Dollar sign when you’re copying the command line.

$ sudo apt install php

For Redhat family, CentOS, Fedora, etc

$ sudo dnf install php

Similarly, use the package manager for your particular distribution to install PHP.

After the PHP installation, now you can easily install Composer. So let’s download the composer installer.

$ curl -Ss https://getcomposer.org/installer | php

Now you have to move the composer.phar file into the /usr/local/bin directory.

$ sudo mv composer.phar /usr/local/bin/composer

After moving the file, it’s time to make it executable.

$ chmod +x /usr/local/bin/composer

The installation has completed, now you can use the composer command-line tool.

$ composer

In future if you want to update the Composer then use this command.

$ sudo composer self-update