Last active
August 19, 2019 03:01
-
-
Save nd3w/ff2b06464121d1aabec7287f37f00d1a to your computer and use it in GitHub Desktop.
Linux Aliases to Switch Amongs PHP Versions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Assuming I have three different PHP versions on my system: | |
1. PHP 5.6 | |
2. PHP 7.1 | |
3. PHP 7.2 | |
To switch two between versions, add these aliases into your ~/.bashrc file: | |
alias php5671='sudo a2dismod php5.6 ; sudo a2enmod php7.1 ; sudo service apache2 restart ; echo 2 | sudo update-alternatives --config php' | |
alias php5672='sudo a2dismod php5.6 ; sudo a2enmod php7.2 ; sudo service apache2 restart ; echo 3 | sudo update-alternatives --config php' | |
alias php7156='sudo a2dismod php7.1 ; sudo a2enmod php5.6 ; sudo service apache2 restart ; echo 1 | sudo update-alternatives --config php' | |
alias php7172='sudo a2dismod php7.1 ; sudo a2enmod php7.2 ; sudo service apache2 restart ; echo 3 | sudo update-alternatives --config php' | |
alias php7256='sudo a2dismod php7.2 ; sudo a2enmod php5.6 ; sudo service apache2 restart ; echo 1 | sudo update-alternatives --config php' | |
alias php7271='sudo a2dismod php7.2 ; sudo a2enmod php7.1 ; sudo service apache2 restart ; echo 2 | sudo update-alternatives --config php' | |
To activate the alias, type command: | |
source ~/.bashrc | |
And you're on. | |
Type 'php5672' in terminal to switch between PHP 5.6 to PHP 7.2. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment