php - is not within the allowed path ?

查看:136
本文介绍了php - is not within the allowed path ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

描述

  • 阿里云 centos6.5
  • LNMP一键安装
  • thinkphp3.2

页面出现500错误, 把错误开启 ini_set('display_errors','1'); error_reporting(E_ALL); 出现下面错误.

Warning: require(): open_basedir restriction in effect. File(/xxxx/wwwroot/api.xxxx.com/ThinkPHP/ThinkPHP.php) is not within the allowed path(s): (/xxxx/wwwroot/api1.xxxx.com/:/tmp/) in /xxxx/wwwroot/api.xxxx.com/index.php on line 35 Warning: require(/xxxx/wwwroot/api.xxxx.com/ThinkPHP/ThinkPHP.php): failed to open stream: Operation not permitted in /xxxx/wwwroot/api.xxxx.com/index.php on line 35 Fatal error: require(): Failed opening required './ThinkPHP/ThinkPHP.php' (include_path='.:') in /xxxx/wwwroot/api.xxxx.com/index.php on line 35

前因

项目由于磁盘空间不足就新增加了一块, 由于原来的移动到新挂载的磁盘中.就出现以上问题. 但是通过https访问却是正常的. http访问就会现在上面错误.

关于配置

php.ini中open_basedir 并没有启用

解决方案

使用的是LNMP一键安装的环境, 当使用其vhost add 来增加虚拟主机时会在php.ini增加open_basedir. 当项目移动目录时, 而没有更改php.ini里的信息就会出现上面问题.

可以修改/usr/local/php/etc/php.ini在末尾里加入:

[HOST=www.xxx.net]
open_basedir=/home/wwwroot/www.xxx.net/:/tmp/
[PATH=/home/wwwroot/www.xxx.net]
open_basedir=/home/wwwroot/www.xxx.net/:/tmp/

其它可能导致出现这个问题

ll -a //查看隐藏文件

.user.ini //如果网站目录有这个文件, 请查看参考答案2

参考答案1
参考答案2

这篇关于php - is not within the allowed path ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆