m1用homebrew搭载php环境

1.nginx的安装

brew install nginx

找到/opt/homebrew/etc/nginx/nginx.conf,把默认端口改为80,再将

# fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

替换为fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

brew services start nginx

然后在浏览器中输入localhost,看见welcome为成功

2.php的安装

确保能成功安装,安装前先输入brew update

然后

brew install php@8.1

brew link php@8.1

设置环境变量
echo 'export PATH="/opt/homebrew/opt/php@8.1/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/php@8.1/sbin:$PATH"' >> ~/.zshrc
export LDFLAGS="-L/opt/homebrew/opt/php@8.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/php@8.1/include"

source ~/.zshrc

然后用php - v查看php版本

brew services start php@8.1

还有一些扩展软件,自行选择是否下载。

posted @ 2022-03-23 15:04  Lindseyyip  阅读(155)  评论(0编辑  收藏  举报