nginx+php报错FileNotFount和403解决
Nginx添加php配置后web页面报错File not found,后台日志显示FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, 这个需要在Nginx配置里加
root /var/www/html;
目录自己定义,需要写在server块儿里和server_name同级,不能写在location块里, 否则php的 location ~ \.php$ 块无法继承这个设置,导致$document_root
变量在 php location 中为空或错误,fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
中$document_root
为空,实际效果相当于尝试访问$fastcgi_script_name
,所以报错。
第二个问题,web页面报错403 forbiden,后台日志显示directory index of "/var/www/html/" is forbidden。这是由于未设置index,server块儿添加
index index.php;
就解决了。
阅读剩余
版权声明:
作者:konoha
链接:https://konoha.cc/nginxphp%e6%8a%a5%e9%94%99filenotfount%e5%92%8c403%e8%a7%a3%e5%86%b3.html
文章版权归作者所有,未经允许请勿转载。
THE END