Many customers who run PHP websites (such as Drupal) in a cPanel hosting with CloudLinux and CageFS, ask us about using composer in cPanel via SSH.
This page describes how to install composer in a cPanel/WHM server with CloudLinux, of course our cPanel comes with composer preinstalled.
This page should be used by system admins who want to make composer via SSH available to their customers in cPanel with CloudLinux/CageFS installed.
Installing Composer
First, SSH to the cPanel/WHM server and become root user.
Next, run these commands to install composer:
cd curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer
Configure CageFS to recognise Composer
Now, as you have installed composer, let’s add it to the CageFS so that users could access it
vim /etc/cagefs/conf.d/composer.cfg
And add this content:
[composer] comment=Allow composer to work on the server paths=/usr/local/bin/composer
Next, update CageFS
cagefsctl --force-update
Test if Composer works for CageFS user
Test to see if it works, become a CageFS user.
su cagefsuser composer self-update
To benefit from (benchmarked) fast cPanel hosting, including free as-is cPanel account migration,