Brew 安装PHP软件
搜索php软件,方便安装自己想要的版本
brew search php
安装
brew install [email protected]
安装时间,根据网络环境不同,请耐心等待。
...
安装完成后,注意查看信息,如:
# 这里是 Apache 环境需要修改的信息 To enable PHP in Apache add the following to httpd.conf and restart Apache: LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> Finally, check DirectoryIndex includes index.php DirectoryIndex index.php index.html The php.ini and php-fpm.ini file can be found in: /usr/local/etc/php/7.2/ [email protected] is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula. # 系统环境变量要修改的信息 If you need to have [email protected] first in your PATH run: echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc For compilers to find [email protected] you may need to set: export LDFLAGS="-L/usr/local/opt/[email protected]/lib" export CPPFLAGS="-I/usr/local/opt/[email protected]/include" To have launchd start [email protected] now and restart at login: brew services start [email protected] Or, if you don't want/need a background service you can just run: php-fpm
设定系统环境变量
打开并编辑环境变量文件
vim ~/.bash_profile
输入对应环境变量
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
注意:如果
wq
提示是只读文件的话,执行wq!
强制保存。执行重载环境变量
source ~/.bash_profile