Skip to content

Instantly share code, notes, and snippets.

@mahfuzul
Last active December 15, 2017 13:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahfuzul/1a3609459bd5860a7217219bff2270a5 to your computer and use it in GitHub Desktop.
Save mahfuzul/1a3609459bd5860a7217219bff2270a5 to your computer and use it in GitHub Desktop.
Switch between Multiple PHP Version on Ubuntu
##From PHP 5.6 => PHP 7.1
Default PHP 5.6 is set on your system and you need to switch to PHP 7.1. Run the following commands to switch for Apache and command line.
#Apache:-
$ sudo a2dismod php5.6
$ sudo a2enmod php7.1
$ sudo service apache2 restart
#Command Line:-
$ 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
==================================
##From PHP 7.1 => PHP 5.6
Default PHP 7.1 is set on your system and you need to switch to PHP 5.6. Now run the following commands to switch for Apache and command line.
#Apache:-
$ sudo a2dismod php7.1
$ sudo a2enmod php5.6
$ sudo service apache2 restart
#Command Line:-
$ 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment