Install Composer 1.x on cPanel or CWP servers Print

  • 2

Composer is a popular dependency manager for PHP, and is used by many scripts nowadays to download copies of common code they might use to function, as well as to update those common codes. Composer is not installed by default on CWP servers, and on modern cPanel version 92+ Composer is shipped as version 2.x which may not be compatible with all apps. So today, we'll show you how to download and install Composer 1.x onto your cPanel or CWP server.

1. Login to SSH as root
We're assuming your server is self-managed, so you'll want to log in to your server as the root user, or a user that can use sudo / su.

2. Download Composer and put it into a common location
Here we're going to download composer.phar and put it in the /usr/local/bin directory.

wget -O /usr/local/bin/composer.phar

3. Add the composer alias to the end of your .bashrc file
Login to SSH as the cPanel or CWP user that needs to use Composer 1.x. Then, execute the following:

echo 'alias composer="php /usr/local/bin/composer.phar"' >> ~/.bashrc

Note that you'll need to do step 3 for every user on your server that needs to use Composer 1.x.

Please note, if you're using CloudLinux OS with CageFS, you'll need to make a new CageFS include file to add the composer.phar into your CageFS skeleton.

First, let's create the file:
nano /etc/cagefs/conf.d/composer.cfg

And add to it:
paths = /usr/local/bin/composer.phar

Then, update the skeleton:
cagefsctl --force-update

Was this answer helpful?

« Back