mac下安装php-cgi有多种方法,这里只介绍比较简单的两个方法;
- 用brew安装
- 直接下载安装XAMPP
如果安装了xcode,那么推荐使用brew来安装php。详细使用方法见官网,这里只说明如何装php-cgi;
$ brew install php55 --with-cgi
如果安装提示没有php55,请用 brew tap homebrew/homebrew-php 后再安装
如上,方法很简单,等安装成功后即可使用;
到XAMPP官网下载Mac版本,双击安装;等安装成功后需要把XAMPP的bin目录设置到 环境变量里面;
-
使用zsh
$ echo 'export PATH=/Applications/XAMPP/bin:$PATH' >> ~/.zshrc $ source ~/.zshrc
-
使用bash
$ echo 'export PATH=/Applications/XAMPP/bin:$PATH' >> ~/.bashrc $ source ~/.bashrc
现在这个安装方法已经不行了。
参考
https://medium.com/@romaninsh/install-php-7-2-xdebug-on-macos-high-sierra-with-homebrew-july-2018-d7968fe7e8b8
macOS Catalina currently bundles PHP 7.3 which is officially supported by the PHP community.
https://medium.com/@romaninsh/macos-high-sierra-with-built-in-php-52bcb5c2398c