幫助中心
這里有最新的使用文檔和教程
使用寶塔配置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選項出錯?