HOW TO INSTALL COMPOSER ON LINUX
Tags: howto, linux, opensource, ubuntu
Published: 2020-04-21 16:09:32

---
title: HOW TO INSTALL COMPOSER ON LINUX
published: true
date: 2020-02-29 21:29:21 UTC
tags: HowTo,Linux,open source,Ubuntu
canonical_url: https://fossnaija.com/install-composer-linux/
---

![how too install composer banner](https://i1.wp.com/fossnaija.com/wp-content/uploads/2020/02/composer-banner.png?w=665&ssl=1)

Composer is a [command-line](https://fossnaija.com/the-anatomy-of-the-linux-command-line/) package manager for the PHP programming language. Composer helps in managing dependencies and libraries that are required when developing [PHP](https://dev.to/xeroxism/how-to-install-lamp-server-in-linux-ubuntu-3c3k) applications.

Soif you’re developing a PHP app and you need some third-partylibraries you can declare them in the “_ **composer.json** _”file; while composer will go ahead to install the libraries andupdate them for you as necessary.

Thesepackages are installed in a directory like “vendor within yourproject directory

Composer will manage the libraries of different PHP projects individually; because definitely different project need different packages or even none at all.

In this post, I would show you how you can install composer on [Ubuntu Linux](https://dev.to/xeroxism/how-to-install-ubuntu-software-deb-package-from-the-command-line-3gn0). Similar steps can be followed with other [distros](https://dev.to/xeroxism/5-top-privacy-and-security-linux-distributions-2n92) of Linux.

### **Requirements**

Foryou to be able to run/use composer you must have [PHP](https://dev.to/xeroxism/how-to-install-the-latest-stable-php-72-in-ubuntu-linux-20kp)(version5.3.2 and above) installed in your system.

Checkhere on how to [installPHP on your system](https://dev.to/xeroxism/how-to-install-lamp-server-in-linux-ubuntu-3c3k).

## **Step1 – Update systems software repositories:**

Usethe command:

```
sudo apt-get update
```

## **Step2 – Then go to the home directory:**

```
cd ~
```

## **Step3 – Download composer:**

```
curl -sS https://getcomposer.org/installer -o composer-setup.php
```

## **Step4 – Verify the installer**

Nowverify that the installer you just downloaded is the same with thelatest version using the SHA-384 hash.

```
 php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
```

Ifsuccessful, you should have a “_Installerverified_”as output.

![composer install commands](https://i1.wp.com/fossnaija.com/wp-content/uploads/2020/02/composer-installation-another-copy.png?resize=665%2C138&ssl=1)<figcaption>Composer installation commands.</figcaption>

## **Step5 – Install composer:**

Thereare two ways to install Composer. Locally as part of your project, orglobally as a system wide executable.Except on very important reasons, it is advisable to install itglobally on your system. And thats what we will do here (i.e. In the/usr/local/bin directory);

```
sudo php composer-setup.php --install-dir=/usr/loacal/bin --finame=composer
```

Theoutput should look like this;

_ **Allsettings correct for using Composer** _

_ **Downloading…** _

_**Composer(Version 1.8.6) successfully installed to: /usr/local/bin/composer**_

_ **Useit: php /usr/local/bin/composer** _

You can type this command to launch composer:

```
composer
```

You should see this:

![running composer](https://i1.wp.com/fossnaija.com/wp-content/uploads/2020/02/composer-launch-output.png?resize=665%2C388&ssl=1)<figcaption>Composer output.</figcaption>

Thereyou have it, composer installed in your system.

**Happy Linux’NG!**

The post [HOW TO INSTALL COMPOSER ON LINUX](https://fossnaija.com/install-composer-linux/) appeared first on [Foss Naija](https://fossnaija.com).