1. 程式人生 > >require(): open_basedir restriction in effect錯誤解決

require(): open_basedir restriction in effect錯誤解決

出現問題的原因:php open_basedir 配置的問題,PHP不能引入其授權目錄上級及其以上的檔案,之所以出現這個問題絕大多數情況是由於伺服器的許可權限制問題。

1、對於windows和linux解決方式基本都一樣的,只是路徑書寫問題需要注意

2、可以嘗試專案根目錄下找到 user.ini 檔案,直接刪除掉看是否能夠解決

3、nginx解決方案:

nginx.conf 或者 conf/vhost 目錄下 你的域名.conf 檔案或fastcgi.conf或vhost.conf,搜尋 open_basedir,把:

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

改為:

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

把目錄的向上擴大,擴大能夠訪問的目錄許可權

4、apache的解決方案:
Apache 需要修改 httpd.conf 或者同目錄下的 vhost 目錄下 你的域名.conf 檔案:

php_admin_value open_basedir "/home/wwwroot/www.thinkphp.cn/wwwroot/:/tmp/:/var/tmp/:/proc/"

改為:

php_admin_value open_basedir "/home/wwwroot/www.thinkphp.cn/:/tmp/:/var/tmp/:/proc/"

5、或者把對應的許可權部分都刪除掉
找到open_basedir的部分,這樣就沒有限定