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

精选文章 2017年10月25日 11K

最近用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/下,所以将权限指定了此目录下面。


关注微信公众号『PHP学习网

第一时间了解最新网络动态
关注博主不迷路~

PHP学习网:站内收集的部分资源来源于网络,若侵犯了您的合法权益,请联系我们删除!
分享到:
赞(0)

文章评论

您需要之后才可以评论
0点赞 0评论 收藏 QQ分享 微博分享

PHP学习网

PHP学习网