安装php相关环境(brew安装请参考:https://blog.youkuaiyun.com/wangzhufei/article/details/109045788)
brew install nginx
brew install redis
brew install mysql@5.7
brew install php@7.4(不写参数则安装最新的)
注1:如果权限问题加sudo
注2:启动和操作 brew services start|restart|stop 软件名
安装php报问题处理
问题一:
And make sure that your user has write permission.
chmod u+w /usr/local/lib/pkgconfig
处理:sudo chmod 777 /usr/local/lib/pkgconfig
问题二:
Error: The following formula
[#<Dependency: "python@3.9" []>, #<Options: []>]
cannot be installed as binary package and must be built from source.
Install the Command Line Tools:
xcode-select --install
处理: 在app store安装 xcode
设置环境变量(brew安装的都在/usr/local/Cellar 目录下)
sudo vim ~/.bash_profile
添加:
export PATH="/usr/local/Cellar/php/7.4.11/bin:$PATH" (给php命令使用)
export PATH="/usr/local/Cellar/php/7.4.11/sbin:$PATH" (给php-fpm命令使用)
保存
sudo vim ~/.zshrc
添加:source ~/.bash_profile
保存
source ~/.zshrc
安装php插件 pecl和swoole(用以下链接)
https://blog.youkuaiyun.com/wangzhufei/article/details/109066565
安装php插件 redis(用以下链接)
https://blog.youkuaiyun.com/wangzhufei/article/details/109069046