记录一次在lnmp环境下部署php框架的排错
Warning: require(): open_basedir restriction in effect. File(/home/wwwroot/project/vendor/autoload.php) is not within the allowed path(s): (/home/wwwroot/project/public/:/tmp/:/proc/) in /home/wwwroot/project/public/index.php on line 14
Warning: require(/home/wwwroot/project/vendor/autoload.php): failed to open stream: Operation not permitted in /home/wwwroot/project/public/index.php on line 14
Fatal error: require(): Failed opening required '/home/wwwroot/project/public/../vendor/autoload.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/project/public/index.php on line 14
描述 : 如果将TP6,Yaf等开发框架部署到centos下的lnmp继承环境下时,会报以上错误,原因是默认是配置不允许跨目录执行:
open_basedir 将php所能打开的文件限制在指定的目录树中,包括文件本身。当程序要使用例如fopen()或file_get_contents()打开一个文件时,这个文件的位置将会被检查。当文件在指定的目录树之外,程序将拒绝打开。
解决方案是修改 /usr/local/nginx/conf/fastcgi.conf文件,将 最后一句配置 fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/"; 注释掉 #
然后lnmp restart重启服务
问题解决