phpblewでPHPのバージョン管理
PHPのバージョン管理ツールphpblewを導入したので、簡単に使い方をまとめておきます。
phpblewのインストール
$ curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew $ chmod +x phpbrew # phpbrewを$PATHから参照できる位置に移動 $ mv phpbrew /usr/local/bin/phpbrew
phpbrewのセットアップ
以下のコマンドを実行してください。
$ phpbrew init
.bashrc
or .zshrc
に以下の記述を追記
[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc
phpbrewを使ってみる
実際にphpbrewを使ってPHP7.0.4をインストールしていきます。
インストール可能なバージョン一覧を表示
$ phpbrew known 7.0: 7.0.11, 7.0.10, 7.0.9, 7.0.8, 7.0.7, 7.0.6, 7.0.5, 7.0.4 ... 5.6: 5.6.26, 5.6.25, 5.6.24, 5.6.23, 5.6.22, 5.6.21, 5.6.20, 5.6.19 ... 5.5: 5.5.38, 5.5.37, 5.5.36, 5.5.35, 5.5.34, 5.5.33, 5.5.32, 5.5.31 ... 5.4: 5.4.45, 5.4.44, 5.4.43, 5.4.42, 5.4.41, 5.4.40, 5.4.39, 5.4.38 ...
PHP7.0.4をインストール
$ phpbrew install 7.0.4 +default Error: Configure failed: The last 5 lines in the log file: checking for alloca... (cached) yes checking for working memcmp... yes checking for stdarg.h... (cached) yes checking for mcrypt support... yes configure: error: mcrypt.h not found. Please reinstall libmcrypt.
エラーでコケました。
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
libmcrypt
をインストールしてね。と言っているので、homebrewでインストールします。
$ brew install mcrypt
再び、インストールしてみます。
$ phpbrew install 7.0.4 +default
古いバージョンのPHPをインストール
https://github.com/phpbrew/phpbrew/wiki/TroubleShooting#version--5322-not-found
インストール中のバージョン一覧を表示
$ phpbrew list * (system) php-7.0.4
バージョンの切り替え
$ phpbrew use 7.0.4
バージョンの確認
$ php --version PHP 7.0.4 (cli) (built: Sep 30 2016 01:25:09) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies