在nginx配置thinkphp项目,访问的时候碰到以下错误

[error] 1196#0: *7 FastCGI sent in stderr: "PHP message: PHP Warning:  require(): open_basedir restriction in effect. File(/srv/www/local.wz/thinkphp/base.php) is not within the allowed path(s): (/srv/www/local.wz/public:/tmp/:/proc/) in /srv/www/local.wz/public/index.php on line 16

解决方法:

1.删除项目根目录下的.user.ini,这个.user.ini可能是lnmp一键安装包配置项目的时候生成的,项目本身没有这个

2.LNMP 1.4上如果不想用防跨目录或者修改.user.ini的防跨目录的目录还需要将 /usr/local/nginx/conf/fastcgi.conf 里面的fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/"; 在该行行前添加 # 或删除改行,需要重启nginx。

 

参考:https://lnmp/faq/lnmp-vhost-add-howto.html#user.ini

更多推荐

FastCGI sent in stderr: "PHP message: PHP Warning: require(): open_basedir