How To Install Composer on CentOS 8

Published on  

3 min read

Looking for other version?

Choose a different version or distribution.

How To Install Composer on CentOS 8

In this guide, we'll walk you through the steps to install Composer on CentOS/RHEL 8

Composer is a popular dependency manager for PHP that simplifies the process of managing your project's dependencies. If you're a CentOS 8 user, installing Composer is a straightforward process that can be completed in just a few minutes.

It is used in popular PHP CMS and Frameworks like Magento and Laravel to manage its components and dependencies. The composer makes use of a composer.json file to specify version and dependency information. In this tutorial, you'll install Composer on CentOS 8. Let's get started.


  • A server with CentOS 8 as OS
  • PHP 5.3.2 or later installed
  • User privileges: root or non-root user with sudo privileges

System Requirements

Composer in its latest version requires PHP 7.2.5 to run. A long-term-support version (2.2.x) still offers support for PHP 5.3.2+ in case you are stuck with a legacy PHP version. A few sensitive php settings and compile flags are also required, but when using the installer you will be warned about any incompatibilities.

Step 1: Update Your System

Before installing any new software on your CentOS 8 system, it's always a good idea to update your system packages to ensure that you have the latest security updates and bug fixes.

To update your system packages, run the following command:

sudo yum clean all && sudo yum -y update

Step 2: Install PHP CLI and Other Dependencies

Composer is written in PHP, so you'll need to have PHP installed on your system before you can install Composer. Run the following command to install PHP:

sudo yum install php

If you already have PHP installed in your system you can skip this step.

Step 3: Install Dependencies

Start by updating your package manager cache and installing the required dependencies, including php-cli:

sudo yum install php-cli php-zip wget unzip curl

Step 4: Install Composer

Now that we have PHP installed, we can install Composer using curl. Run the following commands to download and install Composer:

cd ~
curl -sS -o composer-setup.php

The following command will download and install Composer as a system-wide command named composer, under /usr/local/bin:

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

Step 5: Verify the Installation

Once the installation is complete, you can verify that Composer is installed by running the following command:

composer --version

If Composer is installed correctly, you should see the version number printed in the terminal.


In this guide, we've walked you through the process of installing Composer on CentOS 8. By following these steps, you'll be able to easily manage your project's dependencies and ensure that you have access to the latest features and bug fixes.

If you're interested in learning more about Composer and how it can help streamline your PHP development process, be sure to check out our complete guide to getting started with Composer.

About the Author

Rexposed Staff

Was this helpful?