Created
March 5, 2018 09:25
-
-
Save marek-pietrzak-tg/cdf39b6885b021833ed9e623017fc0a0 to your computer and use it in GitHub Desktop.
Switch PHP version on Ubuntu
This file contains hidden or 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
| #!/bin/bash | |
| PHP_VERSION=$1 | |
| allowed_versions=(7.0 7.1 7.2) | |
| is_allowed=$(printf ",%s" "${allowed_versions[@]}" | grep "$PHP_VERSION" | wc -l) | |
| if [[ "$is_allowed" == "0" ]] ; then | |
| echo "Allowed versions: ${allowed_versions[@]}" | |
| exit 1 | |
| fi | |
| update-alternatives --set php /usr/bin/php$PHP_VERSION | |
| # Apache | |
| # sudo a2dismod php5.6 | |
| # sudo a2enmod php7.1 | |
| # sudo service apache2 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment