微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

laravel项目在lnmp环境上线出现404错误

项目上传到服务器后出现了404错误,查看了错误日志:

PHP message: PHP Warning: UnkNown: Failed to open stream: Operation not permitted in UnkNown on line 0

  

Unable to open primary script: /www/wwwroot/yjx.ycqmd.top/public/index.PHP (Operation not permitted)" while reading response header from upstream, client: 118.78.36.242, server: yjx.ycqmd.top, request: "GET /home/index HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi-71.sock:", host: "tk.ycqmd.top"

  

2020/02/29 18:06:16 [error] 24746#0: *1267 FastCGI sent in stderr: "PHP message: PHP Warning: UnkNown: open_basedir restriction in effect. File(/www/wwwroot/yjx.ycqmd.top/public/index.PHP) is not within the allowed path(s): (/www/wwwroot/xiaoying/:/tmp/:/proc/) in UnkNown on line 0

  

查看问题描述以及资料,发现是open_basedir的问题,PHP不能引入其授权目录上级及其以上的文件

关于open_basedir有三个方法可以修改

1、认配置在PHP.ini(/www/server/PHP/72/etc/PHP.ini)。

不过我的PHP.ini中是认的配置:

;open_basedir =

可以在等号后添加网站的根目录路径

2、在fastcgi.conf(/www/server/Nginx/conf/fastcgi.conf)

fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

或者把$document_root改为网站根目录路径

但是如果服务器有多个项目,这样改就不合适了,这时候可以用第三种方法

3、在.user.ini(根目录)
open_basedir=/www/wwwroot/yjx.ycqmd.top:/tmp/:/proc/

 

如果这几个文件都没有问题,可能是网站的访问入口地址不在根目录(我也是这种问题)

在laravel项目中,会把访问入口地址改为/public,所以.user.ini文件也要放到/public目录下。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐