Please note that this article is considered legacy documentation because cPanel 58 has reached its end-of-life support.
With a tool like Composer it is generally best to have the ability to run it as any user on the server and from any directory. This is generally referred to as being ‘globally installed’ as any user can access the tool from any location. In this guide we will detail how to install Composer globally on a cPanel based VPS server.
Pre-Flight Check
- These instructions are intended specifically for installing Composer on a cPanel based server running WHM prior to version 58.
- We’ll be logging in as root to a Liquid Web Fully Managed cPanel VPS server.
Step #1: Get the installer
Acquire the Composer installer script with the following commands:
EXPECTED_SIGNATURE=$(wget https://composer.github.io/installer.sig -O - -q)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$EXPECTED_SIGNATURE') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
The above commands will: get the installer’s signature, get the installer file, verify the download by checking the signature and finally confirm if the installer is valid, or corrupt. You should see output similar to:
Step #2: Run the installer
To run the installer in a manner that will install composer globally run the following command:php ./composer-setup.php --install-dir=/usr/local/bin --filename=composer
With this command run as root composer should now be globally installed on the server.
Step #3: Verify the install
In order to verify the composer installation was successfully you will want to do the following to test. First, as root, run the following command:# composer -V
You should see something similar to:
If that checks out, you will then want to verify Composer works for the users as well. To confirm composer is working for the cPanel accounts SSH into your server as a cPanel user and do the same:
$ composer -V
You should see something similar to:
David Singer