栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

THINKPHP搭建报错Warning: require(): open

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

THINKPHP搭建报错Warning: require(): open

问题:LNMP 环境下搭建 Thinkphp5 报错如下

Warning: require(): open_basedir restriction in effect. File(/home/wwwroot/store/thinkphp/base.php) is not within the allowed path(s): (/home/wwwroot/store/public/:/tmp/:/proc/) in /home/wwwroot/store/public/install.php on line 18

Warning: require(/home/wwwroot/store/thinkphp/base.php): failed to open stream: Operation not permitted in /home/wwwroot/store/public/install.php on line 18

Fatal error: require(): Failed opening required '/home/wwwroot/store/public/../thinkphp/base.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/store/public/install.php on line 18

解决思路:
因为LNMP默认是不允许跨目录访问的,而TP框架根目录是指向public下的,须访问上一层文件,所以都是必须要将防跨目录访问的设置去掉。

  1. 可以删掉public下面的.user.ini隐藏文件。
    一般要使.user.ini生效,需要打开php.ini 中的这两个参数
    user_ini.filename = “.user.ini”
    user_ini.cache_ttl = 300

  2. 删掉.user.ini还是不可以的话就修改fastcgi.conf(与nginx.conf文件同级目录下)

# 注释
# fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
# 修改为
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/../:/tmp/:/proc/";

修改完后记得重启nginx服务生效。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/881710.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号