Skip to content

Instantly share code, notes, and snippets.

@jonathanbossenger
Created April 29, 2022 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanbossenger/f9d3c686b6d4efd5b3c6081f7f9aba30 to your computer and use it in GitHub Desktop.
Save jonathanbossenger/f9d3c686b6d4efd5b3c6081f7f9aba30 to your computer and use it in GitHub Desktop.
Script to update PHP alternatives after enabling a different PHP version
#!/bin/bash
# Get the PHP version number passed as a variable
PHP_VERSION=${1-''}
if [[ $PHP_VERSION == '' ]]
then
echo "Please pass a PHP version number."
exit
fi
sudo update-alternatives --set php /usr/bin/php"$PHP_VERSION"
sudo update-alternatives --set phar /usr/bin/phar"$PHP_VERSION"
sudo update-alternatives --set phar.phar /usr/bin/phar.phar"$PHP_VERSION"
sudo update-alternatives --set phpize /usr/bin/phpize"$PHP_VERSION"
sudo update-alternatives --set php-config /usr/bin/php-config"$PHP_VERSION"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment