Installing Composer on cPanel servers

Cpanel/Whm License $3/mo Plesk License $10/mo Cloudlinux License $5/mo

  1. Composer 101
  2. Installing Composer on cPanel servers
  3. Working with Composer & Examples
Note:
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 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 sxi.io Web Fully Managed cPanel server.
As of WHM version 58 cPanel is now including a version of Composer by default, this can be accessed by simply calling composer from command line.
For more details see: What’s New in WHM 58 & What to Look For

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:

Installer verified

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:

Composer version 1.2.0 2016-07-19 01:28:52

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:

Composer version 1.2.0 2016-07-19 01:28:52
Series Navigation

<< Composer 101Working with Composer & Examples >>

Related posts

Casa Launches Lightning Node Mobile App for Bitcoin Newbies

SXI ADMIN

Ethereum Is Throwing Out the Crypto Governance Playbook

SXI ADMIN

Bitcoin’s Price Sets New All-Time High

SXI ADMIN

Bitcoin Retirement Fund Provider Adds Ripple in IRA Product Update

SXI ADMIN

Venezuelan Lawmakers Declare Petro Crypto Illegal

SXI ADMIN

Bitcoin on the Dark Web: The Facts

SXI ADMIN

How Do I Set System Variable Path for Python on Windows?

SXI ADMIN

Traders Now Betting 2-to-1 Bitcoin Cash Fork Will Cause Price Decline

SXI ADMIN

Blockchain Could Expand Central Bank Access, Says Bank of Japan

SXI ADMIN

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More