Created
June 24, 2015 13:46
-
-
Save lpeabody/56103fe0f6715def467c to your computer and use it in GitHub Desktop.
PHP Switch
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 | |
if [ $# -ne 1 ]; then | |
echo "Usage: sphp [phpversion]" | |
exit 1 | |
fi | |
currentversion=`php -r "echo str_replace('.', '', substr(phpversion(), 0, 3));"` | |
newversion="$1" | |
brew list php$newversion 2> /dev/null > /dev/null | |
if [ $? -eq 0 ]; then | |
echo "PHP version $newversion found" | |
echo "Unlinking old binaries..." | |
brew unlink php$currentversion 2> /dev/null > /dev/null | |
echo "Linking new binaries..." | |
brew link php$newversion | |
echo "Linking new modphp addon..." | |
sudo ln -sf `brew list php$newversion | grep libphp` /usr/local/lib/libphp5.so | |
echo "Updating version file..." | |
echo "Restarting Apache..." | |
sudo pkill -9 httpd | |
sudo apachectl -k restart > /dev/null 2>&1 | |
echo "Done." | |
else | |
echo "PHP version $newversion was not found." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment