Skip to content

Instantly share code, notes, and snippets.

@singhhrpreet
Created September 27, 2019 21:06
Show Gist options
  • Save singhhrpreet/fec44c6ff248b02076b3d8a037497a2e to your computer and use it in GitHub Desktop.
Save singhhrpreet/fec44c6ff248b02076b3d8a037497a2e to your computer and use it in GitHub Desktop.
# > /dev/null is disable the outputs of the commands
if [ $# -eq 0 ]; then
echo "Provide the PHP version to enable"
exit 0
fi
for php in 5.6 7.1 7.2 7.3
do
if [ $php == $1 ]
then
echo "Enabling PHP v$php"
sudo a2enmod php${php} > /dev/null
fi
if [ $1 != $php ]
then
echo "Disabling PHP v$php"
sudo a2dismod php${php} > /dev/null
fi
done
echo "Restarting Apache Server.."
sudo service apache2 restart
echo "Done.. My Friend.."
@singhhrpreet
Copy link
Author

singhhrpreet commented Sep 27, 2019

If you have multiple PHP versions installed in your linux system.

And you need to enable a certain version and disable others.

Eg.

phpswitcher 7.1

would enable 7.1 and disable all others and also restart apache web server

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