47
59

More than 5 years have passed since last update.

homebrewでインストールした複数のphpのバージョンを切り替える方法

Last updated at Posted at 2016-06-23

homebrewで複数バージョンのphpをインストールして、どちらを使うかを切り替える方法を紹介します。

php5.6のインストール

$ brew install php56

php7.0のインストール

5.6に続いて、7.0を同じようにインストールすることができますが、
その前にunlinkします。

$ brew unlink php56
$ brew install php70

バージョンの切り替え

unlink, linkで切り替えます。
ここまでの状態だと、php7.0になっています。

$ php -v
PHP 7.0.7 (cli) (built: May 27 2016 11:13:44) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

unlinkでphp7.0のシンボリックリンクを削除して、
linkでphp5.6のシンボリックリンクを作成します。

$ brew unlink php70
Unlinking /usr/local/Cellar/php70/7.0.7... 17 symlinks removed

$ brew link php56
Linking /usr/local/Cellar/php56/5.6.22... 17 symlinks created

$ php -v
PHP 5.6.22 (cli) (built: May 27 2016 12:20:55)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
47
59
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
47
59