lnmp|lnmp中关于 open_basedir 的报错

在使用lnmp配置新项目的过程中,报出如下错误.

**Warning**: require(): open_basedir restriction in effect. File(/p/lv/vendor/autoload.php) is not within the allowed path(s): (/var/www/el/:/tmp/:/proc/) in **/var/www/el/index.php** on line **24****Warning**: require(/var/www/el/vendor/autoload.php): failed to open stream: Operation not permitted in **/var/www/el/index.php** on line **24****Fatal error**: require(): Failed opening required '/var/www/el/vendor/autoload.php' (include\_path='.:/usr/local/php/lib/php') in **/var/www/el/index.php** on line **24**

【lnmp|lnmp中关于 open_basedir 的报错】报错日志显示 open_basedir 不在 open_basedir的限定目录里面.那么在哪里可以配置呢? 答案是php.ininginx.conf
我们先来看看php.ini, 发现并没有配置 open_basedir
然后再去看看nginx配置,发现nginx的配置文件比较多 引用比较复杂,没关系,我们使用grep -rn
?nginx grep -rn open_basedir ./ ./conf/fastcgi.conf:27:fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/"; ./conf/fastcgi.conf:28:fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

发现 fastcgi.conf 中配置了open_basedir $document_root, 那么我们只需要再添加一个新的默认目录即可.
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/:/var/www/el/";

    推荐阅读