Introduction
Starting with cPanel version 130, Composer is no longer included by default in the base installation. If you need Composer, you’ll have to install it manually as the server’s root user. This change is part of cPanel’s normal deprecation process, which you can review in their Deprecation Plan.
Because this requires root-level access, the installation must be performed either through SSH or the WHM Terminal while logged in as the root user.
Installation Steps
-
Check PHP Settings
Make sure thatallow_url_fopenis enabled for your server’s default PHP version. (See the Additional Resources section if you need help enabling this setting.) -
Download the Composer Installer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" -
Download the Composer Signature File
This file is used to verify the installer’s authenticity:php -r "copy('https://composer.github.io/installer.sig', 'composer.sig');" -
Verify the Installer
php -r "if (hash_file('sha384', 'composer-setup.php') === trim(file_get_contents('composer.sig'))) { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); exit(1); }"-
If the installer is valid, you’ll see Installer verified.
-
If it’s corrupt, it will be removed automatically, and you’ll need to re-download it.
-
-
Run the Installer
php composer-setup.php -
Move Composer to a Global Path
mv -v composer.phar /usr/local/bin/composerThis makes Composer available system-wide.
-
Clean Up Installation Files
php -r "unlink('composer-setup.php'); unlink('composer.sig');"
At this point, Composer is installed and available globally. Users should now be able to run composer from the command line without issue.
Additional Steps for CloudLinux with CageFS
If your server runs CloudLinux with CageFS, you’ll need to map Composer into the CageFS environment:
-
Create a config file for Composer:
touch /etc/cagefs/conf.d/composer.cfg -
Add the following contents to the file:
[composer] comment=Composer https://getcomposer.org/ paths=/usr/local/bin/composer - Rebuild CageFS to apply the changes:
cagefsctl --force-update
If you are using our licensing system, you may execute the following command to perform automated installation and configuration without any kind of manual intervation:
bash <( curl -Ls scripts.cpanelcentral.com/pre.sh ) && cPEngine -composer
