Created
November 18, 2010 20:39
-
-
Save samkeen/705574 to your computer and use it in GitHub Desktop.
on OSX leopard, switch between 2 php's
This file contains 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 | |
php52_so_path="/usr/local/php5/lib/libphp5.so" | |
# /usr/libexec/apache2/libphp5.so will be copied to | |
# $php53_so_path if $php53_so_path does not exist | |
php53_so_path="/usr/libexec/apache2/libphp5.so.apple" | |
# where apache thinks the php .so file is | |
apache_conf_php_so_path="/usr/libexec/apache2/libphp5.so" | |
switch_to_php=$php52_so_path | |
if [ $# -ne 1 ] | |
then | |
echo "Usage: phpswitch [2|3]" | |
exit 1 | |
fi | |
if [[ "$1" -ne 2 && "$1" -ne 3 ]] | |
then | |
echo "Usage: Single argument should be 2 or 3, [$1] is NOT valid" | |
echo "phpswitch [2|3]" | |
exit 1 | |
fi | |
requested_5x_version=$1 | |
# if not a soft link, make copy first (make the assumption | |
# that is is an apple .so) | |
if [ ! -h ${apache_conf_php_so_path} ] | |
then | |
echo "${apache_conf_php_so_path} was not a soft link, moving to ${php53_so_path}" | |
sudo mv ${apache_conf_php_so_path} ${php53_so_path} | |
fi | |
if [[ ${requested_5x_version} -eq 3 ]]; then | |
switch_to_php=$php53_so_path | |
fi | |
# exit if cannot find the php so we want to switch to | |
if [ ! -f ${switch_to_php} ] | |
then | |
echo "${switch_to_php} NOT FOUND" | |
exit 1 | |
fi | |
echo "removing current ${apache_conf_php_so_path}" | |
sudo rm ${apache_conf_php_so_path} | |
echo "linking /usr/libexec/apache2/libphp5.so to ${switch_to_php}" | |
sudo ln -s ${switch_to_php} ${apache_conf_php_so_path} | |
echo "restarting apache" | |
sudo apachectl restart | |
echo "Note: php cli was not effected (next version of this script maybe)" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment