首页 > 代码库 > lnmp 环境require(): open_basedir restriction in effect 错误

lnmp 环境require(): open_basedir restriction in effect 错误

 

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

技术分享

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

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

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

技术分享

然后检测nginx配置

技术分享

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

技术分享

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

 然后就可以愉快的玩耍了

技术分享

 

lnmp 环境require(): open_basedir restriction in effect 错误