亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Warning:?require():?open_basedir?restriction?in?effect,目錄配置open_basedir報(bào)錯(cuò)問題分析

 更新時(shí)間:2022年11月19日 10:36:57   投稿:yin  
在linux服務(wù)器部署thinkphp5的時(shí)候PHP報(bào)了Warning:?require():?open_basedir?restriction?in?effect這個(gè)錯(cuò)誤,是因?yàn)榫W(wǎng)站目錄配置錯(cuò)誤,PHP不能引入其授權(quán)目錄上級(jí)及其以上的文件。下面詳細(xì)講解如何處理這個(gè)問題,需要的朋友可以參考下

在linux服務(wù)器部署thinkphp5的時(shí)候PHP報(bào)了Warning: require(): open_basedir restriction in effect這個(gè)錯(cuò)誤,是因?yàn)榫W(wǎng)站目錄配置錯(cuò)誤,PHP不能引入其授權(quán)目錄上級(jí)及其以上的文件。下面詳細(xì)講解如何處理這個(gè)問題,需要的朋友可以參考下。

錯(cuò)誤提示如下:

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

出現(xiàn)問題的原因:

查看問題描述以及資料,發(fā)現(xiàn)是php open_basedir 配置的問題,PHP不能引入其授權(quán)目錄上級(jí)及其以上的文件;

解決方法:

我首先要申明的是,下面的方法適合所有報(bào)“PHP報(bào):require(): open_basedir restriction in effect”錯(cuò)誤的項(xiàng)目,并不僅僅只是適合thinkphp5的人。只要你的PHP報(bào)此類似錯(cuò)誤都可以得到解決。

如果把ThinkPHP5部署在了LAMP/LNMP環(huán)境上很有可能出現(xiàn)白屏或500的情況,這個(gè)時(shí)候需要開啟 php 錯(cuò)誤提示來判斷是否是因?yàn)樵O(shè)置了open_basedir選項(xiàng)出錯(cuò)?

打開 php.ini 搜索 display_errors,把 Off 修改為 On就開啟了 php 錯(cuò)誤提示,這時(shí)再訪問之前白屏的頁面就會(huì)出現(xiàn)錯(cuò)誤信息。如果錯(cuò)誤信息如下那么很有可能就是因?yàn)閛pen_basedir的問題。

注意:下面方法中的目錄路徑可能跟你的不一樣,注意換成自己的文件目錄路徑。

一、php.ini 修改方法

把權(quán)限作用域由入口文件目錄修改為框架根目錄

打開 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 設(shè)置選項(xiàng)是被注釋的或者為 none,那么你需要通過 Apache 或者 Nginx 來修改> php.ini 文件通常是在 /usr/local/php/etc 目錄中,當(dāng)然了這取決于你 LAMP 環(huán)境配置。

二、Apache 修改方法

Apache 需要修改 httpd.conf 或者同目錄下的 vhost 目錄下 你的域名.conf 文件,如果你的生成環(huán)境是 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/"

然后重新啟動(dòng) apache 即可生效

> 域名.conf 文件通常是在 /usr/local/apache/conf 目錄中,當(dāng)然了這取決于你 LAMP 環(huán)境配置

三、Nginx/Tengine 修改方法

Nginx 需要修改 nginx.conf 或者 conf/vhost 目錄下 你的域名.conf 文件,如果你的生成環(huán)境是 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/";

然后重新啟動(dòng) Nginx 即可生效

域名.conf 文件通常是在 /usr/local/nginx/conf/vhost 目錄中,當(dāng)然了這取決于你 LNMP/LTMP 環(huán)境配置

注意:上面我們修改的時(shí)候用的是絕對(duì)地址,但是也可以這樣直接去找網(wǎng)站根目錄(如果你這樣配置,你一定要懂不同項(xiàng)目有不同根目錄的原理,否則也是行不通的。):

fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

上面這行代碼拿thinkphp來講,如果你根目錄是public,那么$document_root就會(huì)指到public;

依然會(huì)生成錯(cuò)誤的配置如下:

fastcgi_param  PHP_VALUE  "open_basedir=/home/wwwroot/www.thinkphp.cn/public/:/tmp/:/proc/";

四、fpm/fastcgi user.ini 修改方法

打開 項(xiàng)目根目錄下找到 user.ini 文件,搜索 open_basedir,把

open_basedir=/home/wwwroot/www.thinkphp.cn/public/:/tmp/:/proc/

修改為

open_basedir=/home/wwwroot/www.thinkphp.cn/:/tmp/:/proc/

然后重新啟動(dòng) web 服務(wù)器 即可生效

總結(jié):

一般情況下是不會(huì)出現(xiàn)這種問題的,之所以出現(xiàn)這個(gè)問題絕大多數(shù)情況是由于服務(wù)器的原因,為了安全才做了這樣的限制!也有可能是一開始網(wǎng)站目錄配置錯(cuò)誤,因?yàn)閠hinkphp5的根目錄在public文件夾。一定要根據(jù)自己的服務(wù)器環(huán)境來選擇你的修改方法。

到此這篇關(guān)于Warning: require(): open_basedir restriction in effect,目錄配置open_basedir報(bào)錯(cuò)問題分析的文章就介紹到這了,更多相關(guān)require(): open_basedir目錄配置報(bào)錯(cuò)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論