Skip to content

Instantly share code, notes, and snippets.

@nataliaalves03
Last active November 15, 2022 21:29
Show Gist options
  • Save nataliaalves03/ca7fa8e478b6da8402a39cea967d1ee8 to your computer and use it in GitHub Desktop.
Save nataliaalves03/ca7fa8e478b6da8402a39cea967d1ee8 to your computer and use it in GitHub Desktop.
Set PHP version
#!/bin/sh
ERROR="\e[91m"
INFO="\e[94m"
SUCCESS="\e[92m"
ENDCOLOR="\e[0m"
if [ -z "$1" ]; then
echo "${ERROR}Missing PHP version. Try: sh php-version.sh 8.1${ENDCOLOR}"
exit 0
fi
echo "${INFO}Setting PHP version $1 ${ENDCOLOR}"
sudo update-alternatives --set php /usr/bin/php$1
sudo update-alternatives --set phar /usr/bin/phar$1
sudo update-alternatives --set phar.phar /usr/bin/phar.phar$1
echo "${SUCCESS}Done! Check the PHP version...${ENDCOLOR}"
php --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment