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

install composer cpanel search easyapache

2. Click on the EasyApache 4 to enable PHP modules

3. Click on the buttonCustomize.

install composer cpanel open easyapache4

4. Navigate to PHP Extensions section

install composer cpanel navigate php

5. Search for extensionsIconv & Mbstring to install.

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

install composer cpanel open search mbstring extension
install composer cpanel search Iconv extension

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

install composer cpanel provision modules

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:

DirectiveRequired value

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

install composer cpanel open php multi ini editor

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

install composer cpanel edit php ini

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:

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 1.7.3) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

You should be able to use composer command

  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
Composer version 1.7.3 2018-11-01 10:05:06

  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 1.7.3 2018-11-01 10:05:06

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

Complete Web Development Course:

Other Cpanel articles available are:

How to add PHPZIP Archive in cPanel

Configure Cpanel Firewalld on CentOS 7

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here