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