laravel在lnmp环境下报错Warning: require(): open_basedir restriction in effect的问题解决

前几天在lnmp下搭建了一个laravel框架,一切都很顺利,但是打开首页的时候一直报以下错误

Warning: require(): open_basedir restriction in effect. File(/p/lv/vendor/autoload.php) is not within the allowed path(s): (/p/lv/public/:/tmp/:/proc/) in /p/lv/public/index.php on line 24

Warning: require(/p/lv/vendor/autoload.php): failed to open stream: Operation not permitted in /p/lv/public/index.php on line 24

Fatal error: require(): Failed opening required '/p/lv/public/../vendor/autoload.php' (include_path='.:/usr/local/php/lib/php') in /p/lv/public/index.php on line 24

后来网上查询到解决方案:

最近配置开发用的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 错误 - 猴子请我来帮忙 - 博客园

Warning: require(): open_basedir restriction in effect. File(/home/framework/laravel/ - CSDN博客

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容