# How to install Composer on Ubuntu 20.04

In just a few steps, you can install the [PHP](https://www.ionos.ca/digitalguide/websites/website-creation/learn-php-our-all-encompassing-php-tutorial-for-beginners/ "Learn PHP: Our all-encompassing PHP tutorial for beginners") package manager Composer on Ubuntu 20.04. The installation can be performed on the [Linux distribution](https://www.ionos.ca/digitalguide/server/configuration/linux-distributions/ "Linux distributions") through the terminal.

## How to install Composer on Ubuntu 20.04 step by step

Installing Composer on Ubuntu 20.04 takes just a few minutes. All you need for the installation is the Linux Terminal.

Note If you are not using [Ubuntu](https://www.ionos.ca/digitalguide/server/know-how/ubuntu-the-linux-system-for-everyone/ "Ubuntu : The Linux system for everyone") 20.04, you may find it helpful to check out one of the following articles on installing Composer:

- [Install Composer on Ubuntu 22.04](https://www.ionos.ca/digitalguide/server/configuration/how-to-install-composer-on-ubuntu-2204/)
- [Install Composer on Windows 10](https://www.ionos.ca/digitalguide/server/configuration/php-composer-installation-on-windows-10/)
- [Install Composer on Windows 11](https://www.ionos.ca/digitalguide/server/configuration/php-composer-installation-on-windows-11/)

### Step 1: Update the system

Before getting started with the Ubuntu installation of Composer, ensure that your system is up to date. To do this, open the terminal and run the following command:

```bash
sudo apt update
sudo apt upgrade
```

You’ll be prompted to enter your password because the above commands are executed with root computers.

### Step 2: Install required packages

Once you’ve successfully updated your system, you can install the packages required for Composer. These include the PHP Command Line Interface and the curl command line utility. If you’ve already installed the required packages on your system, you can skip this step. Otherwise, use this command to begin installation:

```bash
sudo apt install curl php-cli php-mbstring git unzip
```

### Step 3: Download and install Composer

To install Composer on Ubuntu 20.04, all you need is a command line command. It’ll use the curl tool you just downloaded to install the required files for Composer from the official website. Composer will then be installed on your system.

```bash
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
```

After the installation of Composer is finished, a message will appear in your terminal indicating that the installation was successful:

[![Image: Terminal view after installing PHP Composer](https://www.ionos.ca/digitalguide/fileadmin/_processed_/1/2/csm_composer-successfully-installed_a2d810aeb8.webp "Terminal view after installing PHP Composer")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2023/composer-successfully-installed.png) Once you’ve finished installing Composer on Ubuntu 20.04, the terminal will let you know and highlight the Composer version you’re using. ### Step 4: Check installation

Next, you should manually verify the installation of Composer by entering the following command:

```bash
composer
```

Finally, you should see a list in the terminal with the most important Composer commands and your current Composer version:

[![Image: Terminal view after launching PHP Composer](https://www.ionos.ca/digitalguide/fileadmin/_processed_/7/4/csm_composer-version_eaab04ab5e.webp "Terminal view after launching PHP Composer")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2023/composer-version.png) You can launch Composer using the “composer” command and view all the commands that you can run from the package manager. If running Composer causes any issues on your system, it may be because the folder where you installed Composer (*usr/local/bin*) is not included in your $PATH environment variable.

Tip Did you know that you can [use Composer with IONOS web hosting plans](https://www.ionos.ca/digitalguide/websites/web-development/using-php-composer-in-ionos-webhosting-packages/ "Using Composer with IONOS web hosting plans")? [Web hosting](https://www.ionos.ca/hosting/web-hosting "Web hosting from IONOS") from IONOS offers built-in DDoS protection and support for current PHP versions such as [PHP 8](https://www.ionos.ca/digitalguide/websites/web-development/php-8/ "PHP 8").

## How to add and update dependencies in Composer

Once you’ve successfully installed the package manager, you can start using the tool and adding dependencies to your projects.

### Create *composer.json* file

The *composer.json* file is where you describe the dependencies of your PHP project. You can create the file manually or have it set up automatically when you create your first dependency. For more detailed settings in the *composer.json* file, it’s best to create it manually using the Composer command:

```bash
composer init
```

### Add dependencies

The main purpose of Composer is to create and manage dependencies in your project. You can add dependencies with a single command:

```bash
composer require monolog/monolog
```

In the example above, the logging library Monolog has been added as a dependency.

### Update dependencies

Using Composer, you can also update your project’s dependencies with the following command:

```bash
composer update
```


This is a markdown version of: [https://www.ionos.ca/digitalguide/server/configuration/php-composer-installation-on-ubuntu-2004/](https://www.ionos.ca/digitalguide/server/configuration/php-composer-installation-on-ubuntu-2004/) for AI/LLM consumption.