It is usually recommended to download Composer to a local user home directory and use a local version that skips workarounds as required by using a root-level version.
Only root is able to update system-level Composer. Local users can update Composer only if they install Composer locally and are not using the root-level Composer provided by cPanel. Follow the below steps to update Composer as root.
- First, check the version of Composer install on your cPanel server.
Composer version 2.1.9 2021-10-05 09:47:38
- Run the following command as root.
- If Composer is an older version, an update will be installed; else following will be output to the terminal.
You are already using the latest available Composer version 2.1.9 (stable channel).
- In case you want to roll back to the previous version, use the following command.
/opt/cpanel/composer/bin/composer self-update --rollback
Some Composer commands from its plugins and scripts feature such as exec, update, and install, allow third party code to execute on your server. Plugins and scripts will have full access to the user account which runs Composer. It is highly recommended to avoid running Composer as the root user.
composer install --no-plugins --no-scripts ...
composer update --no-plugins --no-scripts ...