How to Install Composer in CageFS for cPanel/CloudLinux
This guide explains how to make Composer available globally to all cPanel users under CageFS safely.
STEP 1: INSTALL COMPOSER GLOBALLY
If Composer is not already installed on the server, run the following commands as root:
cd /tmp
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
php -r "unlink('composer-setup.php');"
STEP 2: CONFIGURE CAGEFS
Create a configuration file to allow CageFS to see the Composer binary.
- Create the file:
nano /etc/cagefs/conf.d/composer.cfg - Add the following content:
[composer]
comment=Composer
paths=/usr/local/bin/composer -
Update CageFS:cagefsctl --force-update
STEP 3: VERIFY FOR A CPANEL USER
Switch to a cPanel user to verify the installation:
su - username
composer --version
The user will automatically use the PHP version selected in their CloudLinux PHP Selector.