Created
September 18, 2012 05:32
-
-
Save STAR-ZERO/3741437 to your computer and use it in GitHub Desktop.
php-buildとphpenvを使ってphpをインストール
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
| ・個人的なメモなので環境によってはうまく動かないかも | |
| ・Apache、php-build、phpenvはHomebrewでインストールしたやつを使用 | |
| ・Apacheのモジュールを作成して退避する | |
| ・事前に/usr/local/share/php-build/default_configure_optionsに--with-apxs2=/usr/local/sbin/apxsを追加しておく | |
| ・使い方 | |
| ~/.phpenv/libexec に配置して実行権限を付与 | |
| $ phpenv apache-install 5.3.15 でインストール |
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
| #!/usr/bin/env bash | |
| set -e | |
| [ -n "$RBENV_DEBUG" ] && set -x | |
| # Provide rbenv completions | |
| if [ "$1" = "--complete" ]; then | |
| echo system | |
| exec rbenv-versions --bare | |
| fi | |
| if [ "$1" = "--definitions" ]; then | |
| exec php-build --definitions | |
| exit | |
| fi | |
| RBENV_VERSION="$1" | |
| RBENV_VERSION_FILE="${RBENV_ROOT}/version" | |
| if [ -z "$RBENV_VERSION" ]; then | |
| echo "usage: phpenv install VERSION" | |
| exit 1 | |
| fi | |
| # apache path | |
| APACHE_ROOT=$(brew --prefix httpd) | |
| APACHE_MODULE_PATH="${APACHE_ROOT}/libexec" | |
| APXS_PATH=`which apxs` | |
| RBENV_PREFIX_PATH="${RBENV_ROOT}/versions/${RBENV_VERSION}" | |
| if [ -d "$RBENV_PREFIX_PATH" ]; then | |
| echo "Version already exists" >&2 | |
| exit 1 | |
| fi | |
| PHPBUILD_CONFIG_PATH="/usr/local/share/php-build" | |
| if [ ! -d "$PHPBUILD_CONFIG_PATH" ]; then | |
| echo "php-build not installed" >&2 | |
| exit 1 | |
| fi | |
| if [ -z `grep "\--with-apxs2=${APXS_PATH}" "${PHPBUILD_CONFIG_PATH}/default_configure_options"` ]; then | |
| echo "Add the \"--with-apxs2=${APXS_PATH}\" file to \"${PHPBUILD_CONFIG_PATH}/default_configure_options\"" >&2 | |
| exit 1 | |
| fi | |
| # remove libphp5.so | |
| if [ -f "${APACHE_MODULE_PATH}/libphp5.so" ]; then | |
| rm $APACHE_MODULE_PATH/libphp5.so | |
| fi | |
| echo "install start..." | |
| php-build $RBENV_VERSION $RBENV_PREFIX_PATH | |
| echo "move apache module" | |
| mv $APACHE_MODULE_PATH/libphp5.so $RBENV_PREFIX_PATH | |
| phpenv rehash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment