Monday, November 20, 2017

How to switch between PHP 5.6 to 7.1 and vice versa

How to switch between PHP 5.6 to 7.1 and vice versa

You can have more than one php version installed on your system, for example you have php 5.6 and php 7.1, but only one can be active at the moment, so basically you can switch back and forth between the two easily, no need to uninstall one version in order to use the other. In this tutorial i will show you how to switch from php 5.6 to php 7.1 and vice versa.

Before we begin, you need to understand that we need to run command in two level, first the web server level in this case we are using apache web server, and the second is on command line level where you run php command line interface.

Switch from PHP 5.6 to PHP 7.1 

Web server level
sudo a2dismod php5.6
sudo a2enmod php7.1
sudo service apache2 restart

Command line level
sudo update-alternatives --set php /usr/bin/php7.1
sudo update-alternatives --set phar /usr/bin/phar7.1
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.1


Switch from PHP 7.1 to PHP 5.6

Web server level
sudo a2dismod php7.1
sudo a2enmod php5.6
sudo service apache2 restart

Command line level
sudo update-alternatives --set php /usr/bin/php5.6
sudo update-alternatives --set phar /usr/bin/phar5.6
sudo update-alternatives --set phar.phar /usr/bin/phar.phar5.6

No comments:

Post a Comment