How To Install PHP Composer on Cpanel

Posted on 22 views

In this guide, we will cover the installation of PHP Composer on Cpanel. Composer is a PHP dependency management tool. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

Composer doesn’t come pre-installed with PHP or Cpanel and you’ll have to install it manually. Follow our steps below to install PHP Composer on Cpanel.

Step 1: Install required PHP modules in EasyApache

To use Composer, you must enable several PHP modules in EasyApache.

1. Login to your Cpanel WHM dashboard and search for EasyApache


2. Click on the EasyApache 4 to enable PHP modules

3. Click on the buttonCustomize.


4. Navigate to PHP Extensions section


5. Search for extensionsIconv & Mbstring to install.

6. Click on install toggle to enable installation for these extensions



7.  On the Review Page, click the buttonProvision to install the extensions.


8. If the installation was successful, you should receive the message Provision process finished. Click Done.

Step 2: Set required PHP directives

You must update the following PHP directives in the php.ini file:

Directive Required value
allow_url_fopen On
detect_unicode Off

1. Navigate to WHM > MultiPHP INI Editor > Editor Mode


2. Edit the INI settings of a PHP version on the dropdown menu. Add the following lines at the end of the php.ini file.

allow_url_fopen = On
detect_unicode = Off

It should look like below


You must click “Save” to apply the new changes.

Step 3:  Install PHP Composer on Cpanel Server

Now that we have our dependencies set correctly, ssh into your Cpanel Server and download Composer installer:

wget -O composer-installer.php

Run the installer script to deploy Composer globally:

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

You should see output like below:

All settings correct for using Composer

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

You should be able to use composer command

  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
Composer version 2.2.7 2022-02-25 11:12:27

  command [options] [arguments]

  -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

To check for the installed version of composer, type the command:

$ composer -V
Composer version 2.2.7 2022-02-25 11:12:27

Here you go!. You now have Composer dependency Manager for PHP installed on your Cpanel Server.


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.