在Mac上同时安装PHP7.1、PHP7.0、PHP5.6和PHP5.5

冲泡的准备

假设已经安装了HomeBrew。

在homebrew/homebrew-php上安装PHP。

> brew tap homebrew/homebrew-php
> brew install php70 && brew unlink php70
> brew install php56 && brew unlink php56
> brew install php71 && brew unlink php71

切换 (qiē

为了更改PHP的版本,安装php-switcher,避免使用brew unlink php56 && brew link php71这样麻烦的方法。

~ $ brew install brew-php-switcher
==> Installing brew-php-switcher from homebrew/php
==> Downloading https://homebrew.bintray.com/bottles-php/brew-php-switcher-1.6.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring brew-php-switcher-1.6.sierra.bottle.tar.gz
==> Caveats
To run brew php switcher do the following:
  "brew-php-switcher 53".

You can select php version 53, 54, 55, 56, 70 or 71.
==> Summary
?  /usr/local/Cellar/brew-php-switcher/1.6: 7 files, 8.2KB

就是这种感觉

~ $ brew-php-switcher 70
Switching to php70
Switching your shell
Unlinking /usr/local/Cellar/php56/5.6.32_8... 0 symlinks removed
Unlinking /usr/local/Cellar/php70/7.0.22_14... 0 symlinks removed
Unlinking /usr/local/Cellar/php71/7.1.11_22... 17 symlinks removed
Linking /usr/local/Cellar/php70/7.0.22_14... 17 symlinks created
You will need sudo power from now on
Switching your apache conf
Password:
Sorry, try again.
Password:
Restarting apache
All done!
bannerAds