Skip to content

Instantly share code, notes, and snippets.

@marek-pietrzak-tg
Created March 5, 2018 09:25
Show Gist options
  • Select an option

  • Save marek-pietrzak-tg/cdf39b6885b021833ed9e623017fc0a0 to your computer and use it in GitHub Desktop.

Select an option

Save marek-pietrzak-tg/cdf39b6885b021833ed9e623017fc0a0 to your computer and use it in GitHub Desktop.
Switch PHP version on Ubuntu
#!/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