Symptoms
When running a PHP Composer command on the command line, the command fails, and you receive the following warning:
Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI
Description
This occurs if the user does not have the proper aliases set up in their bash configuration. It is caused by the PHP or Composer alias referring to the incorrect path. Please note that this only applies to installations of Composer configured before cPanel v130. For installing Composer after cPanel v130, please refer to the following article:
How to install composer on cPanel version 130 and higher.
Workaround
- Access your server using SSH as the cPanel user who has Composer installed. This cannot be the root user.
- Using your preferred text editor, open the user's .bashrc file for editing:
/home/user/.bashrc
- Add the following alias to the bottom of the file. You will need to refer directly to the PHP binary the user is configured to use:
alias composer='/opt/cpanel/ea-phpXX/root/usr/bin/php /opt/cpanel/composer/bin/composer'
- Save the file and close the editor. The next time an SSH session is launched for that user, the configuration will be reloaded. You can re-source the config file to have the changes take effect immediately:
source /home/user/.bashrc
Comments
0 comments
Article is closed for comments.