Magento 2.0.2 CE – CLI Commands Not Working After Upgrading to PHP 7

bin-magentoclimagento-2.0.2php-7

I've upgraded the php version of the apache2.4 server from 5.6 to 7.0.
OS version Ubuntu 14.04 LTS.
After this update, despite the fact that I've installed php7.0-cli, when i try to run

php7.0 bin/magento list command 

I get the fallowing output:

Content-type: text/html; charset=UTF-8

bin/magento must be run as a CLI application

Output when I run sudo apt-get install php7.0-cli:

php7.0-cli is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

When I go to the bin directory and try to run the command :

magento list

I get the output:

magento: command not found

Any help would be appreciated!

Best Answer

what is the output of:

ls -l $(which php)

For me this is showing:

/usr/bin/php -> /etc/alternatives/php

Also check the output of this:

echo $PATH

And look for any path to the wrong php, maybe you only need to fix the $PATH.

If this is not working try this to reinstall the whole package, overwriting the original files:

sudo apt-get install --reinstall php7.0-cli