require(): 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
解决方法:
我首先要申明的是,下面的方法适合所有报“PHP报:require(): open_basedir restriction in effect”错误的项目,并不仅仅只是适合thinkphp5的人。只要你的PHP报此错误都可以得到解决。
如果把ThinkPHP5部署在了LAMP/LNMP环境上很有可能出现白屏的情况,这个时候需要开启 php 错误提示来判断是否是因为设置了open_basedir选项出错。
打开 php.ini 搜索 display_errors,把 Off 修改为 On就开启了 php 错误提示,这时再访问之前白屏的页面就会出现错误信息。如果错误信息如下那么很有可能就是因为open_basedir的问题。
一、php.ini 修改方法
把权限作用域由入口文件目录修改为框架根目录
打开 php.ini 搜索 open_basedir,把
open_basedir = "/home/wwwroot/tp5/public/:/tmp/:/var/tmp/:/proc/"
修改为
open_basedir = "/home/wwwroot/tp5/:/tmp/:/var/tmp/:/proc/"
注意:
如果你的 php.ini 文件的 open_basedir 设置选项是被注释的或者为 none,那么你需要通过 Apache 或者 Nginx 来修改> php.ini 文件通常是在 /usr/local/php/etc 目录中,当然了这取决于你 LAMP 环境配置。
二、Apache 修改方法
Apache 需要修改 httpd.conf 或者同目录下的 vhost 目录下 你的域名.conf 文件,如果你的生成环境是 LAMP 一键安装包配置那么多半就是直接修改 你的域名.conf 文件
apache
├─vhost
├─www.thinkphp.cn.conf
├─......
├─httpd.conf
打开 你的域名.conf 文件 搜索 open_basedir,把
php_admin_value open_basedir "/home/wwwroot/www.thinkphp.cn/public/:/tmp/:/var/tmp/:/proc/"
修改为
php_admin_value open_basedir "/home/wwwroot/www.thinkphp.cn/:/tmp/:/var/tmp/:/proc/"
然后重新启动 apache 即可生效
> 域名.conf 文件通常是在 /usr/local/apache/conf 目录中,当然了这取决于你 LAMP 环境配置
三、Nginx/Tengine 修改方法
Nginx 需要修改 nginx.conf 或者 conf/vhost 目录下 你的域名.conf 文件,如果你的生成环境是 LNMP/LTMP 一键安装包配置那么多半就是直接修改 你的域名.conf 文件
nginx
├─conf
├─vhost
├─www.thinkphp.cn.conf
├─nginx.conf
├─......
├─nginx.conf
打开 你的域名.conf 文件 搜索 open_basedir,把
fastcgi_param PHP_VALUE "open_basedir=/home/wwwroot/www.thinkphp.cn/public/:/tmp/:/proc/";
修改为
fastcgi_param PHP_VALUE "open_basedir=/home/wwwroot/www.thinkphp.cn/:/tmp/:/proc/";
然后重新启动 Nginx 即可生效
> 域名.conf 文件通常是在 /usr/local/nginx/conf/vhost 目录中,当然了这取决于你 LNMP/LTMP 环境配置
四、fpm/fastcgi user.ini 修改方法
打开 项目根目录下找到 user.ini 文件,搜索 open_basedir,把
open_basedir=/home/wwwroot/www.thinkphp.cn/public/:/tmp/:/proc/
修改为
open_basedir=/home/wwwroot/www.thinkphp.cn/:/tmp/:/proc/
然后重新启动 web 服务器 即可生效
总结:
一定要仔细读此篇文章,否则你会选错适合你的方法。
一定要根据自己的服务器环境来选择你的修改方法。
require(): open_basedir restriction in effect. 解决方法的更多相关文章
- LNMP - Warning: require(): open_basedir restriction in effect错误解决方法
LNMP 1.4或更高版本如果不想用防跨目录或者修改.user.ini的防跨目录的目录还需要将 /usr/local/nginx/conf/fastcgi.conf 里面的fastcgi_param ...
- open_basedir restriction in effect,解决php引入文件权限问题 解决方法
如下: 出现问题的原因: 查看问题描述以及资料,发现是php open_basedir 配置的问题,PHP不能引入其授权目录上级及其以上的文件: 一般情况下是不会出现这种问题的,之所以出现这个问题绝大 ...
- php 环境require(): open_basedir restriction in effect 错误
php 环境require(): open_basedir restriction in effect 错误 错误日志显示,访问脚本不在 open_basedir的限定目录里面 解决方法打开fastc ...
- thinkPHP5配置nginx环境无法打开(require(): open_basedir restriction in effect. File(/mnt/hgfs/root/tp5/thinkphp/start.php) is not within the allowed path(s)
今天想把玩一下tp5,结果怎么都无法访问,每次都是报500错误,我把错误提示都打开看到下面的错误 require(): open_basedir restriction in effect. File ...
- Warning: require(): open_basedir restriction in effect. File(/www/wwwroot/../thinkphp/start.php) is not within the allowed path(s):
Warning: require(): open_basedir restriction in effect. File(/www/wwwroot//../thinkphp/start.php) is ...
- require(): open_basedir restriction in effect. File
新安装的 lnmp 环境,将项目放上报 require(): open_basedir restriction in effect. File 的错误! 错误日志显示,访问脚本不在 open_base ...
- php错误提示 open_basedir restriction in effect 解决
<VirtualHost *:80> DocumentRoot "D:/www/4w_raaaa_com_2017" ServerName www.raaaa.com: ...
- require(): open_basedir restriction in effect. File(/www/wwwroot/xcx/zerg/thinkphp/start.php) is not within the allowed path(s): (/www/wwwroot/xcx/zerg/public/:/tmp/:/proc/) in /www/wwwroot/xcx/zerg/p
解决方法: 在如下文件增加一项(如图所示) 在如下文件增加一项(如图所示): #php文件采用fastcgi解析并设置参数 location ~ \.php { try_files ...
- lnmp 环境require(): open_basedir restriction in effect 错误
最近配置开发用的lnmp环境,环境配置完成后,爆500错误,查看nginx错误日志 open_basedir 将 PHP 所能打开的文件限制在指定的目录树,包括文件本身 错误日志显示,访问脚本不在 o ...
随机推荐
- C语言再学习之 setjmp与longjmp
前不久在阅读Quake3源代码的时候,看到一个陌生的函数:setjmp,一番google和查询后,觉得有必要针对setjmp和longjmp这对函数写一篇blog,总结一下. setjmp和longj ...
- mysql一个字符问题
顺便记录一下在使用mysql过程中碰到的一些问题: 有时候使用脚本迁移数据时会碰到乱码的问题,即使将表字符集设置成utf8也无济于事,这个时候在执行sql之前加一句set names utf8即可.
- csu 1548(三分)
1548: Design road Time Limit: 2 Sec Memory Limit: 256 MBSubmit: 383 Solved: 200[Submit][Status][We ...
- JAVA 抽象类、接口
一.抽象类 1.语法定义 在类前面使用 abstract 修饰的类就是抽象类 2.应用场景: (1)在某些情况下,某个父类只是知道其子类应该包含怎样的方法,但无法准确知道这些子类如何实现这些方法. ( ...
- MVC – 3.EF(Entity Framework)
1.实体框架(EF)简介 与ADO.NET的关系 全称是ADO.NET Entity Framework,是微软开发的基于ADO.NET的ORM(Object/Relational Mapping)框 ...
- spring_150807_hibernate_transaction_annotation
实体类: package com.spring.model; import javax.persistence.Entity; import javax.persistence.Id; import ...
- mvc3 RenderAction传参问题
我在viewA中调用部分视图viewB代码如下:@{Html.RenderAction("NewsList","News",new{pageSize=13, c ...
- centos6.5 下安装mysql5.7
http://blog.csdn.net/cryhelyxx/article/details/49757217 按步骤一路执行下去. 以下是补充: linux下,在mysql正常运行的情况下,输入my ...
- 阿里云ecs 服务器配置
阿里云ecs 7.0+安装mysql 5.6 http://jingyan.baidu.com/article/454316ab67bd02f7a7c03af4.html 安装jdk yum -y i ...
- 【转载】Xutils3源码解析
Github源码地址:https://github.com/wyouflf/xUtils3 原文地址 :http://www.codekk.com/blogs/detail/54cfab086c476 ...