INSTALLING PHP 5.6 ON UBUNTU
#apt-get install python-software-properties
# sudo add-apt-repository ppa:ondrej/php
# sudo apt-get update
# sudo apt-get install -y php5.6
Check Installed PHP Version:
# php -v
We can see version of php as 5.6
#apt-get install python-software-properties
#add-apt-repository ppa:ondrej/php
#apt-get update
#apt-get install -y php7.1
Check Installed PHP Version:
#php -v
If you have installed multiple php versions and want to use
different than default. Use following steps to switch between php5.6 and php7.1
version. You can use the same command for other php versions.
From php 5.6 to 7.1
#a2dismod php5.6
This disables php 5.6. Now we wamt to enable php 7.1
#a2enmod php7.1
Inorder to make it effective we have to restart apache2 service
#service apache2 restart
#update-alternatives --set php /usr/bin/php7.1
Similarly we can also do it for php 7.1 to php 5.6.
From PHP 7.1 to 5.6
#a2dismod php7.1
#a2enmod php5.6
#service apache2 restart
#update-alternatives --set php /usr/bin/php5.6