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 in my PC. But when I check php version in phpInfo() and in CLI It still 7.1. How can I swith php to that version.

andranik 200
add comment

1 Answer


To swith php7.1 to php5.6 you need to 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

add comment

Your Answer