美文网首页
访问PHP文件报错File not found

访问PHP文件报错File not found

作者: 薛延祥 | 来源:发表于2021-03-22 19:19 被阅读0次

    1、配置完LNMP环境后访问PHP文件,报错

    File not found

    解决办法:

    1、确认nginx、php-fpm、项目的路径都配置无误,且服务均启动。

    2、确认运行nginx、php-fpm服务的用户具有访问项目代码的权限

    3、nginx解析php文件的默认配置是否更改

    这种情况下,查看nginx的error.log文件,发现报错的原因是:

    2021/03/22 19:10:57 [error] 2702#0: *4 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:1111"

    FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

    问题产生的原因是解析php文件时使用了默认的nginx配置

    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

    修改为

    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

    即可

    相关文章

      网友评论

          本文标题:访问PHP文件报错File not found

          本文链接:https://www.haomeiwen.com/subject/rnlthltx.html