PHP文件访问时提示http 404错误


PHP文件访问时提示http 404错误

文章插图
 
刚安装好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文件
<?phpphpinfo();原因:
nginx和php的root根目录未设置对 , 如果代码都在同一目录下 , 可在server{}下设置全局root , 不用单独在location{}里设置rootroot /main/web/www#另外/scripts 修改为 $document_rootlocation ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
【PHP文件访问时提示http 404错误】


    推荐阅读