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

发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章