require(): open_basedir restriction in effect

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了require(): open_basedir restriction in effect相关的知识,希望对你有一定的参考价值。

LNMP环境安装Laravel,在nginx.conf将root指向项目的public目录的时候(如:root /home/wwwroot/laravel/public),浏览器运行报500错误,错误信息为:
Warning: require(): open_basedir restriction in effect. File(/home/wwwroot/laravel/vendor/autoload.php) is not within the allowed path(s): (/home/wwwroot/laravel/public/:/tmp/:/proc/:/home/wwwroot/laravel/public/) in /home/wwwroot/laravel/public/index.php on line 24

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

Fatal error: require(): Failed opening required ‘/home/wwwroot/laravel/public/../vendor/autoload.php‘ (include_path=‘.:/usr/local/php/lib/php‘) in /home/wwwroot/laravel/public/index.php on line 24

1、查找php.ini 发现“open_basedir”为注释状态
2、查看nginx下的fastcgi.conf ,发现“fastcgi_param”参数如下
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
这里的$document_root 就是 nginx中定义的root的目录
3、修改nginx下的fastcgi.conf,在后面追加上项目的根目录,如下:
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/:/home/wwwroot/laravel/";
4、重启lnmp ,错误消失。

以上是关于require(): open_basedir restriction in effect的主要内容,如果未能解决你的问题,请参考以下文章

宝塔Warning: require(): open_basedir restriction i

lnmp 环境require(): open_basedir restriction in effe

宝塔面板出现“require(): open_basedir restriction in effect. ”的解决方法

require(): open_basedir restriction in effect

require(): open_basedir restriction in effect. 解决方法

宝塔部署项目报Warning: require(): open_basedir restriction in effect的解决方案