加入收藏 | 设为首页 | 会员中心 | 我要投稿 大庆站长网 (https://www.0459zz.com/)- 科技、智能边缘云、事件网格、云计算、站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

php – 如何在nginx vhost中添加open_basedir路径

发布时间:2020-09-18 18:03:44 所属栏目:Nginx 来源:互联网
导读:在php.ini我已经设置open_basedir = /home/user/web/ 现在我想在子域上运行phppgadmin,它需要包含来自/usr/share / phppgadmin的文件.所以我将以下行添加到此主机的nginx-config中:fastcgi_param PHP_VALUE open_basedir=/home/user/web/

在php.ini我已经设置

open_basedir = /home/user/web/

现在我想在子域上运行phppgadmin,它需要包含来自/usr/share / phppgadmin的文件.
所以我将以下行添加到此主机的nginx-config中:

fastcgi_param PHP_VALUE open_basedir="/home/user/web/:/usr/share/phppgadmin/";

并重新启动nginx.但是,由于以下错误,我无法访问该网站:

[error] 31440#0: *1 FastCGI sent in stderr: “PHP Warning: include_once(): open_basedir restriction in effect. File(/usr/share/phppgadmin/libraries/lib.inc.php) is not within the allowed path(s): (/home/user/web/) in /usr/share/phppgadmin/info.php on line 10

可能是第二条路径没有列在这里的原因是什么?我还需要将open_basedir添加到虚拟主机中吗?我只使用/ sites-available中的默认文件.

编辑总是想到重新启动fpm …

service php5-fpm restart
最佳答案 对于您的特定情况,您应该考虑将/usr/share添加到默认的open_basedir中,因为其中的任何内容都设计为由世界读取.

另外,open_basedir很容易被规避,除非你已经锁定了shell_exec,exec,系统和类似的PHP函数,所以不要认为使用它是安全的(我知道,它很糟糕).

如果你想知道如何轻松绕过它,你可以只使用system(‘php -n ascript.php’);. -n将导致不读取PHP.ini,因此不会应用open_basedir.

(编辑:大庆站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读