Skip to content
Follow
Ubuntu Linux

How to Install PHP Composer on Ubuntu Linux

Richard
Written by
Richard
Aug 22, 2020 Updated Jul 14, 2026 3 min read
Enable Automatic Suspension in Ubuntu Linux Easily
Enable Automatic Suspension in Ubuntu Linux Easily

PHP Composer installs on Ubuntu Linux using simple terminal commands.

PHP Composer acts as the main tool for managing outside code, called libraries, that your PHP projects need to run. It lets you easily add and keep track of these libraries.

Getting Composer set up on Ubuntu 22.04 LTS, or other newer versions, is a clear process. This ensures you have the newest features for handling your project’s code needs.

Before you start, make sure you have PHP version 7.4 or a newer one already installed on your Ubuntu computer.

⚡ Quick Answer

Install Composer on Ubuntu by running `curl -sS https://getcomposer.org/installer | sudo php — –install-dir=/usr/local/bin –filename=composer` in your terminal. This command downloads and installs Composer globally. Verify the installation by typing `composer`.

Install PHP

You can install PHP on your Ubuntu system using a simple command in the terminal. This command installs the default PHP version that comes with Ubuntu’s software. If you require a different PHP version, you may need to add an extra software source before running the installation command.

🐧Bash / Shell
sudo apt install php
💡Tip
If you need to install other PHP versions unavailable in Ubuntu default repositories for your system, run the commands below to install a third-party repository containing PHP 7.2, 7.3, 7.4, and up.
🐧Bash / Shell
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt update

Now simply run the commands below to install PHP 7.4. change the number value to install 7.2, 7.3, and so forth.

🐧Bash / Shell
sudo apt install php7.4

Install Composer

After you have PHP installed on your Ubuntu system, installing PHP Composer is straightforward with a single command. This command downloads Composer and sets it up so you can manage your PHP project’s needs from any folder, making it much easier to handle required libraries.

🐘PHP
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
📝Good to Know
The commands above will download Composer from its maintainer page and install it into the /usr/local/bin directory. This is a local-global directory for application executables.
🐘PHP
All settings correct for using Composer
Downloading.

Composer (version 1.6.4) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

Now simply run the commands below to test whether Composer is installed.

composer

The output should look like something below.

💻Code
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ / __ `__ / __ / __ / ___/ _ / ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
____/____/_/ /_/ /_/ .___/____/____/___/_/
                    /_/
Composer version 1.6.4 2018-04-13 12:04:24

Usage:
  command [options] [arguments]

Options:
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

When you want to install a PHP-based application that requires Composer, simply reference this page to learn how to install Composer. After that, continue with getting your PHP application on Ubuntu.

Composer can also be upgraded by running specific commands. Running `composer self-update` upgrades Composer itself to the latest version, while running `composer update` upgrades all packages managed by your Composer project, ensuring your dependencies are current and secure.

🐧Bash / Shell
sudo composer self-update

That’s it!

Conclusion:

In summary, installing PHP Composer on Ubuntu is a straightforward process that enhances your ability to manage PHP dependencies effectively. Here are the key points to remember:

  • PHP Composer is essential for managing PHP package dependencies, allowing for easier installation and updates.
  • Ensure that PHP 5.3 or higher is installed before attempting to install Composer.
  • The installation process involves configuring your package sources, installing PHP, and then Composer.
  • Composer commands can be used to manage packages as well as update Composer itself when necessary.
  • Refer back to this guide whenever you need to install Composer for your PHP projects on Ubuntu.

By following these steps, you can efficiently manage your PHP applications and their dependencies.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Install PHP on Ubuntu Linux
Ubuntu Linux How to Install PHP on Ubuntu Linux

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *