Created
December 8, 2010 11:36
-
-
Save nojimage/733166 to your computer and use it in GitHub Desktop.
php switch (php5.2 <-> php5.3) for macports
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
#!/usr/bin/env bash | |
## | |
# php switch (php5.2 <-> php5.3) for macports | |
# | |
# @original http://mark-story.com/posts/view/updating-to-php5-3-with-macports | |
# | |
PORT_BIN=/opt/local/bin/port | |
APACHECTL_BIN=/opt/local/apache2/bin/apachectl | |
function get_ports_installed_version(){ | |
echo `${PORT_BIN} installed ${1} | tail -n 1 | awk '/${1}/ {print $2}'` | |
} | |
function activate_php5_subpackages(){ | |
for name in `${PORT_BIN} installed php5-* | grep -e '@5.3' | grep -v '(active)' | awk '{print $1}'`;do | |
local LAST_VERSION | |
LAST_VERSION=`get_ports_installed_version ${name}` | |
${PORT_BIN} activate ${name} ${LAST_VERSION} | |
done | |
} | |
function deactivate_php5_subpackages(){ | |
for name in `${PORT_BIN} installed php5-* | grep -e '@5.3' | grep -e '(active)' | awk '{print $1}'`;do | |
local LAST_VERSION | |
LAST_VERSION=`get_ports_installed_version ${name}` | |
${PORT_BIN} deactivate ${name} ${LAST_VERSION} | |
done | |
} | |
PHP52_VERSION=`get_ports_installed_version "php52"` | |
PHP53_VERSION=`get_ports_installed_version "php5"` | |
## main | |
${APACHECTL_BIN} stop | |
case "$1" in | |
'php52') | |
${PORT_BIN} deactivate php5 | |
deactivate_php5_subpackages | |
${PORT_BIN} activate php52 $PHP52_VERSION | |
cp -f /opt/local/etc/php5/php52.ini /opt/local/etc/php5/php.ini | |
;; | |
'php5') | |
${PORT_BIN} deactivate php52 | |
${PORT_BIN} activate php5 $PHP53_VERSION | |
activate_php5_subpackages | |
cp -f /opt/local/etc/php5/php53.ini /opt/local/etc/php5/php.ini | |
;; | |
esac | |
${APACHECTL_BIN} start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
バージョン切り替えはCGI版でやるのが楽だよなと思いつつ、モジュール版での切り替え用sh