快捷导航

香港云服务器安装宝塔后open_basedir restriction

[复制链接]
查看: 910|回复: 0
发表于 2023-6-29 15:34:37 | 显示全部楼层 |阅读模式
使用宝塔配置laravel站点时,遇到open_basedir restriction in effect. 原因与解决方法

linux服务器部署thinkphp5的时候PHP报了这个错误,如下:

Warning: require(): open_basedir restriction in effect. File(/www/wwwroot/zhuyuyun/thinkphp/start.php) is not within the allowed path(s): (/www/wwwroot/zhuyuyun/public/:/tmp/:/proc/) in /www/wwwroot/zhuyuyun/public/index.php on line 20

Warning: require(/www/wwwroot/zhuyuyun/thinkphp/start.php): failed to open stream: Operation not permitted in /www/wwwroot/zhuyuyun/public/index.php on line 20

Fatal error: require(): Failed opening required '/www/wwwroot/zhuyuyun/public/../thinkphp/start.php' (include_path='.:/www/server/php/56/lib/php') in /www/wwwroot/zhuyuyun/public/index.php on line 20

或者报如下类似:

Warning: include_once(): open_basedir restriction in effect. File(../../staticpayb/WxPay.Config) is not within the allowed path(s):

出现问题的原因:

查看问题描述以及资料,发现是php open_basedir 配置的问题,PHP不能引入其授权目录上级及其以上的文件;

一般情况下是不会出现这种问题的,之所以出现这个问题绝大多数情况是由于服务器的原因,为了安全才做了这样的限制!

解决方法:

我首先要申明的是,下面的方法适合所有类似PHP报“open_basedir restriction in effect”错误的项目,并不仅仅只是适合thinkphp5的人。只要你的PHP报此错误都可以得到解决。

如果把ThinkPHP5部署在了LAMP/LNMP环境上很有可能出现白屏或500的情况,这个时候需要开启 php 错误提示来判断是否是因为设置了open_basedir选项出错?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

精彩推荐

尚云驿站

  • 投诉建议:350467567@qq.com
  • 软文投稿:350467567@qq.com
  • 友情链接:350467567@qq.com

云服务支持

精彩文章,快速检索

Copyright 尚云驿站  Powered by©  技术支持:飛    ( 闽ICP备2025116718号-15 )