天天看点

lnmp 环境执行yii项目出错 require(): open_basedir restriction in effect 错误

1、最近配置开发用的lnmp环境,环境配置完成后,爆500错误,查看nginx错误日志:

2、open_basedir 将 PHP 所能打开的文件限制在指定的目录树,包括文件本身

错误日志显示,访问脚本不在 open_basedir的限定目录里面,配置open_basedir 一般会在php.ini 或 nginx 配置文件里面

首先检测php.ini 我发现并没有配置 open_basedir 

3、cd /usr/local/nginx/进入nginx目录,在nginx目录下检测nginx配置

cd /usr/local/nginx/

grep -rn open_basedir ./

[注]执行完grep -rn open_basedir ./ 出现 :  /conf/fastcgi.conf:27:#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

发现 fastcgi.conf 中配置了open_basedir $document_root指向的是网站跟目录 /home/www/yii/web,我的项目用的是php2.0 框架需要解析

/home/www/yii 下面的php文件,

由于我配置的是开发环境 ,简单粗暴就把fastcgi.conf 里面open_basedir给注释掉了,线上环境建议 把$document_root 更改为 需要解析的网站目录