How to Install PHP Composer on Ubuntu 20.04

Install PHP Composer on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure PHP Composer on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Composer is a popular dependency management tool for PHP, created mainly to facilitate installation and updates for project dependencies. It will check which other packages a specific project depends on and install them for you, using the appropriate versions according to the project requirements. Composer is also commonly used to bootstrap new projects based on popular PHP frameworks,


  • Operating System with Ubuntu 20.04
  • Server IPv4 Address with Superuser Privileges (Root Access)
  • Gnome Terminal for Linux Desktop
  • PuTTy SSH client for Windows or macOS
  • Powershell for Windows 10/11
  • Familiar with APT Commands

Install PHP Composer on Ubuntu 20.04

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade
sudo apt install php libapache2-mod-php php-mbstring php-xmlrpc php-soap php-gd php-xml php-cli php-zip cur

Step 2. Install PHP Composer on Ubuntu.

Run the following command to download the latest PHP Composer version:

curl -sS | php

Then, make PHP Composer globally available, move it to the binary folder /usr/local/bin as below:

sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer
source ~/.bashrc

At last, you can verify the installation by typing:

$ composer -v
Composer version 1.10.6 2020-06-20 12:46:21

That’s all you need to do to install Composer on Ubuntu 20.04. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.