How to Install Composer on CentOS 7

Install Composer on CentOS 7

In this article, we will have explained the necessary steps to install and configure Composer on CentOS 7. 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 one of the best dependency management tools for PHP which can install and update project dependency seamlessly. When installing a package it also checks on which another package current package depends and then it installs all the dependencies.

Prerequisite:

  • Operating System with CentOS 7
  • 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 YUM Commands

Install Composer on CentOS

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo yum install epel-release
sudo yum update

Step 2. Install Composer on CentOS 7.

First, download and install Composer by executing the following command:

curl -sS https://getcomposer.org/installer | php

Once the process completes, you can make the ‘composer.phar’ file executable by running the following command:

chmod +x composer.phar

Next, make Composer globally available for all system users:

mv composer.phar /usr/local/bin/composer

Run the following command to confirm the installation:

composer -V

To learn more about Composer and find out how to get started with using this package manager, our recommendation is to read the official documentation at https://getcomposer.org/doc/.

Congratulation, you have learned how to install and configure Composer on CentOS 7. If you have any question, please leave a comment below.