Skip to content

Instantly share code, notes, and snippets.

@thisismzm
Last active May 3, 2018 23:51
Show Gist options
  • Save thisismzm/51a68eccfea554cad684d5892a2f2ee2 to your computer and use it in GitHub Desktop.
Save thisismzm/51a68eccfea554cad684d5892a2f2ee2 to your computer and use it in GitHub Desktop.
This is a bash script for switch between PHP versions that are enable as Apache2 webserver module.
#!/bin/bash
sudo update-alternatives --set php "/usr/bin/php$2";
sudo update-alternatives --set "php-config" "/usr/bin/php-config$2";
sudo update-alternatives --set phpize "/usr/bin/phpize$2";
sudo a2dismod "php$1"
sudo a2enmod "php$2"
sudo service apache2 restart
@thisismzm
Copy link
Author

You can use it with the following command:

chmod +x path/to/file/exphp
path/to/file/exphp 5.6 7.2

This will switch PHP5.6 to PHP7.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment