【踩坑】NginxPHP部署完成后访问报错

前言

NginxPHP部署完成后访问报错:File not found.

原因

  • 文件没找到

解决问题

  • Nginx配置文件的location块中的root字段配置不正确

root中不能使用~作为当前用户的home目录

  • Nginx配置文件的location块中的fastcgi_param字段要将/scripts$fastcgi_script_name改成$document_root$fastcgi_script_name
/opt/homebrew/etc/nginx/nginx.conf
1
2
3
4
5
6
7
location ~ \.php$ {
root /opt/homebrew/var/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

完成

参考文献

CSDN——aoh7115497530534