LNMP - Warning: require(): open_basedir restriction in effect錯誤解決方法


LNMP 1.4或更高版本如果不想用防跨目錄或者修改.user.ini的防跨目錄的目錄還需要將 /usr/local/nginx/conf/fastcgi.conf 里面的fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/"; 在該行行前添加 # 或刪除改行,需要重啟nginx。

出現此類問題一般為open_basedir的問題(open_basedir的值來設置限制訪問的目錄或刪除來移除防跨目錄的設置。)
 
Warning: require(): open_basedir restriction in effect. File(/home/wwwroot/xlboo.com/bootstrap.php) is not within the allowed path(s): (/home/wwwroot/xlboo.com/public/:/tmp/:/proc/) in /home/wwwroot/xlboo.com/public/index.php on line 7

Warning: require(/home/wwwroot/xlboo.com/bootstrap.php): failed to open stream: Operation not permitted in /home/wwwroot/xlboo.com/public/index.php on line 7

Fatal error: require(): Failed opening required '/home/wwwroot/xlboo.com/public/../bootstrap.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/xlboo.com/public/index.php on line 7
 
 
方法一
刪除user.ini
去權后刪除即可
chattr -i .user.ini
此方法限制於當前的站點解決
php.ini的說明:https://lnmp.org/faq/lnmp-vhost-add-howto.html#user.ini
 
 
方法二
編輯
vim /usr/local/nginx/conf/fastcgi.conf
 
刪除或注釋掉這一行(*注釋的話前面加“#”號即可)
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
 
此方法限制於所有的LNMP站點解決
 
 
方法三
編輯user.ini
chattr -i .user.ini
vimuser.ini

open_basedir=/home/wwwroot/xlboo.com/:/tmp/:/proc/
改為
open_basedir=/home/wwwroot/xlboo.com/public/ :/tmp/:/proc/
然后
chattr +i .user.ini
最后重啟PHP或者Nginx
重啟PHP
/etc/init.d/php-fpm restart
重啟Nginx
service nginx restart


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM