Macos用Brew安装了nginx替代自带的apache,安装后部分配置如下:

  1. 配置/opt/homebrew/etc/nginx/nginx.conf,删除php系列注释
    • Fastcgi_pass 这行的地址从步骤2获取
  2. 从文件/opt/homebrew/etc/php/8.3/php-fpm.d/www.conf中获取Fastcgi_pass地址
  3. 如果出现404错误,尝试更改nginx配置文件中的fastcgi_param 为SCRIPT_FILENAME $document_root$fastcgi_script_name;

Nginx -t 测试配置文件是否正确

Nginx -s reload 重新载入配置文件