JAVA和Nginx 教程大全

网站首页 > 精选教程 正文

每日学点2---PHP文件访问时提示http 404错误

wys521 2024-09-29 23:25:46 精选教程 223 ℃ 0 评论

刚安装好nginx+php服务后,测试phpinfo页是否显示正确,却提示http 404错误

nginx的错误提示如下:

2019/08/14 11:25:27 [error] 119533#0: *6 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.0.62, server: , request: "GET......

phpinfo.php文件

<?php
phpinfo();

原因:

nginx和php的root根目录未设置对,如果代码都在同一目录下,可在server{}下设置全局root,不用单独在location{}里设置root
root /main/web/www
#另外/scripts 修改为 $document_root
location ~ \.php$ {
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
 }

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表