How to change PHP CLI and Apache versions on Ubuntu

Ask a question+

I have a project which works with PHP 5.6. So I installed php5.6 on my PC. But when I check PHP version in phpInfo() and in CLI It still 7.1. How can I switch PHP to that version?

andranik 300
add comment

1 Answer


To switch php7.1 to php5.6, you should run this command for Apache
sudo a2dismod php7.1
sudo a2enmod php5.6
sudo service apache2 restart

and for command line you need to run.
sudo update-alternatives --set php /usr/bin/php5.6

You can check this

Andranik Hovhannisyan 1.3K
add comment

Your Answer