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

Warning: require_once(): open_basedir restriction in effect 错误

最近用lnmp的一键安装包配置了开发环境,在事件运行项目时碰到了此类错误:Warning: require_once(): open_basedir restriction in effect,经过反复查找原因后发现是open_basedir的问题。

0pen_basedir解释:将 PHP 所能打开的文件限制在指定的目录树,包括文件本身。

首先查看了PHP.ini的open_basedir,发现open_basedir是关闭的。

; open_basedir, if set, limits all file operations to the defined directory

; and below. This directive makes most sense if used in a per-directory

; or per-virtualhost web server configuration file.

; http://PHP.net/open-basedir

;open_basedir =

然后在检查Nginx的fasecgi.conf 配置了open_basedir $document_root指向的是网站跟目录。

修改前:

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

修改后:

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

由于网站都放在了/home/wwwroot/下,所以将权限指定了此目录下面。

原文地址:https://www.toutiao.com/article/7116010293351711269/

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

相关推荐