How to fix Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI error in SSH?

Put this in your bash profile and run source ~/.bashrc alias composer="/opt/cpanel/ea-php71/root/usr/bin/php /opt/cpanel/composer/bin/composer" As Composer is now available via WHM you can use this to find it: which composer This returned path “/opt/cpanel/composer/bin/composer” for me. If this returns nothing then disregard the rest of this answer, as Composer is not available to you at system level. You can now use php-cli to call this with Composer’s absolute path: php-cli /opt/cpanel/composer/bin/composer install php-cli /opt/cpanel/composer/bin/composer update php-cli /opt/cpanel/composer/bin/composer require whatever/example You may however need to alias php-cli if your system claims this isn’t found. It very much depends how PHP has been deployed on the WHM server. Learn how to fix PHP CLI error. You can do this by adding a user alias to the end of your “.bashrc” or “.bash_profile” file as follows: ...

February 12, 2019 · 1 min · Harshvardhan Malpani

Fix Magento 2 – php cli error on cpanel or other hostings

The problem: On a fresh install of Magento2 on cpanel based hosting, you receive the following error while running any command on SSH [eee@e1 www]$ php bin/magento cache:clean X-Powered-By: PHP/7.0.31 Content-type: text/html; charset=UTF-8 bin/magento must be run as a CLI application [eee@e1 www]$ php bin/magento setup:upgrade X-Powered-By: PHP/7.0.31 Content-type: text/html; charset=UTF-8 bin/magento must be run as a CLI application The Solution: You have to point php to correct binary; Use the following code in order: First, open the file which can alter the runtime variables like .bash_profile or .bashrc ...

September 10, 2018 · 1 min · Harshvardhan Malpani