MacのPHPをPHP5.6にバージョンアップする
PHPUnitをインストールしようとしたらPHPのバージョンが古いと言われたので、PHPの5.6にバージョンアップしました。以下、その時の手順です。
環境
- MacOS Sierra 10.12.2
PHP5.6へのバージョンアップの手順
とりあえずhomebrewでPHP5.6のインストールを試みてます。
% brew install php56 Warning: josegonzalez-php/Formula/php56-5.6.13_2 already installed
すでにインストールされてるとエラーが出ました。うーん?そんなはずは無いんだが…(´・ω・`) brew updateでパッケージの一覧の更新を行い、再度PHP5.6のインストールを行ってみます。
% brew update Please run brew update! Homebrew no longer needs to have ownership of /usr/local. If you wish you can return /usr/local to its default ownership with: sudo chown root:wheel /usr/local
% brew install php56 Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). ==> Updated Formulae github-keygen telegraf Error: Formulae found in multiple taps: * homebrew/php/php56 * josegonzalez/php/php56 Please use the fully-qualified name e.g. homebrew/php/php56 to refer the formula.
Formulaが見つからないと言われました。brew tapでjosegonzalez/phpのリポジトリを追加します。
% brew untap josegonzalez/php Untapping josegonzalez/php... (684 files, 7.0M) Untapped 638 formulae
PHP5.6をインストールしてみます。
% brew install php56 Updating Homebrew... ==> Installing php56 from homebrew/php Error: php56-5.6.13_2 already installed To install this version, first `brew unlink php56`
インストールするためには無効化して、と言われたので現状のPHP5.6のパッケージを無効化します。
% brew unlink php56 Unlinking /usr/local/Cellar/php56/5.6.13_2... 17 symlinks removed
PHP5.6のインストールをしてみます。
% brew install php56 Error: No available formula with the name "homebrew/apache/httpd24" Please tap it and then try again: brew tap homebrew/apache ==> Searching for similarly named formulae... Error: No similarly named formulae found. ==> Searching taps... Error: No formulae found in taps.
homebrew/apache/httpd24は利用できないよとエラーが出ました。homebrew tapで、 homebrew/apacheのリポジトリをhomebrewに追加します。
% brew tap homebrew/apache
homebrewでPHP5.6をインストールします。
% brew install php56
エラーも出なかったので、うまくいったっぽいです。
次に、.zprofileに環境パスを追加します。bashを使っている場合は、.bash_profileに追加します。
% vi .zprofile
export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH" export PATH="/usr/local/sbin:$PATH"
.zprofileを再読み込みします。
$ source .profile
phpのバージョンを確認します。
% php -v PHP 5.6.29 (cli) (built: Dec 13 2016 18:47:30) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
無事バージョンアップできました!なかなか時間かかったー。