How to Install Composer on Ubuntu / Linux

How to install Composer on a Linux/Ubuntu environment. This is step by step guide for easy installation.


How to Install Composer on Ubuntu / Linux

Composer is a popular dependency/package manager used in most PHP projects. If you are PHP developer, installing composer is the next step after you install the web and database servers on your development environment. Installing Composer is not that hard on Windows and the good news is it is even easier on Ubuntu, in my case Ubuntu 20.04.

Install PHP First

You need to install PHP first if it is not already available on your system.

First update the package managers datababse

sudo apt update

Next install PHP using the following command

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

Download and Install Composer

Installing Composer is very simple as it provides an installation wizard made with PHP.

Switch to your home directory and download composer installer.

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

Start installer using the command below

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

The installer will download and install composer automatically. When you see a message like below than you are done!

All settings correct for using Composer

Downloading... Composer (version 2.0.9) successfully installed to: /usr/local/bin/composer

Use it: php /usr/local/bin/composer

You can confirm the installation with the following command

composer --version

And if everything is ok you will see output like this

Composer version 2.0.9 2021-01-27 16:09:27

Congratulations and happy PHP coding.

Have any question, suggestion or comment?

Evren Bal

I am Evren BAL

I've been an ‘Internet Creature’ since 1996!

More info about About Evren BAL

If you want to meet one-on-one, feel free to contact me via social media.

Reach Me Out

Reach Me Out

  • Have a question?
  • Noticed a mistake in the article?
  • Have a suggestion about the page?
  • Have a suggestion for an aticle topic?

Reach me out using the contact form or via my social media accounts.

Digital Ocean Logo

Want to try a free VPS?

Using my referral link, you may create a new Digital Ocean account with $100 credit valid for 60 days. This gives you the opportunity to try even the highest performing VPS.

My advice will be to start with a VPS that is feasible and affordable to use after the trial, so that the time you spend on setting up the server is not wasted.

Get your free credits here

You don't have to pay any penny, if you don't want to continue at the end of 60-day trial. If you prefer to continue with the paid service, your first $25 order will reward me $25 free credit that I can use for my hosting

In other words, you will get 100$ credit anyway, and I'll get a 25$ credit if you continue with the paid service in the long run.

Copyright © 2023 - Evren BAL