1.安装 homebrew
https://www.jianshu.com/p/abea83253671
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew tap homebrew/homebrew-php
2.Homebrew安装PHP(new!)
https://www.jianshu.com/p/4189c878da21
brew install php@7.1
最后根据上述安装后的结果执行
echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.bash_profile export LDFLAGS="-L/usr/local/opt/php@7.1/lib" export CPPFLAGS="-I/usr/local/opt/php@7.1/include" source ~/.bash_profile