Cart Control panel
Article overview

Help article

Installing composer in Linux

Composer is a tool for dependency management in PHP. With this, you can easily indicate which libraries your project needs (the dependencies) and Composer then manages these for you.

In this tutorial we show how to install Composer on a server with Ubuntu, Debian, or CentOS.


Requirements

 

Composer requires PHP 5.3.2 or newer. For security reasons, we recommend using the newest version of PHP (7.4 at the time of writing).

For the installation of an Apache server with PHP, you can use our tutorials for installing Apache with PHP support. You're not required to install Apache if you don't want to host a website and can instead only use the steps that deal with PHP.

In addition to the basics that come with installing PHP, Composer requires php-cli php-zip wget and unip. You install these as follows (often they will be installed already if you've installed PHP):

 

CentOS:

sudo yum -y install php-cli php-zip wget unzip

Ubuntu / Debian:

sudo apt-y install php-cli php-zip wget unzip

Installing Composer

 

Step 1

Connect to your VPS using command-line or the VPS console.


 

Step 2

Download the composer installer with the command:

sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

 

Step 3

Check the integrity of the script with the commands:

HASH="$(wget -q -O - https://composer.github.io/installer.sig)"
sudo php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

You get the following output if everything went well, if not, download the installation script again:

Installer verified

 

Step 4

Finally, install Composer in the /usr/local/bin directory (so it is available to all users) with the command:

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

After installation, you can remove the installer with the command:

sudo rm composer-setup.php

 

Should you have any questions left regarding this tutorial, do not hesitate to contact our support department. You can reach them via the ‘Contact Us’ button at the bottom of this page.

If you want to discuss this article with other users, please leave a message under 'Comments'.

Do you have a good idea?

Give us your idea! If it's popular we'll add it to the wishlist!

Has this article been helpful?

Create an account or log in to leave a rating.

Comments

Create an account or log in to be able to leave a comment.

Are you stuck?

Ask one of our specialists to assist you

Contact us