比较来自世界各地的卖家的域名和 IT 服务价格

如何添加方式 open_basedir 在 nginx vhost

在 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. 但是,由于下一个错误,我无法访问该网站:

[错误] 31440 # 0: * 1 FastCGI 发表于B. stderr: "警告 PHP: include_once (): 局限性 open_basedir 行为。 文件 (/usr/share/phppgadmin/libraries/lib.inc.php) 在允许的道路之外 (s):

(/ 主要的 / 用户 / 网络 /)

在 /usr/share/phppgadmin/info.php 排队 10

什么可能是未指定此处的第二路径的原因? 还有什么需要添加 open_basedir 在虚拟主机上? 我只使用了默认文件 / sites-available.

编辑

总是考虑重启 fpm ...

service php5-fpm restart
已邀请:

龙天

赞同来自:

在您的特定情况下,您应该只添加

/usr/share

默认

open_basedir

, 由于一切都在那里,无论如何,旨在阅读世界。

一个好处,

open_basedir

如果没有阻止,容易到处

shell_exec

,

exec

,

system

和类似的功能 PHP, 所以不要考虑使用它安全 (我知道它很糟糕).

如果你对绕过它有多容易感兴趣,你可以

system('php -n ascript.php');

. 在

-n

不会读 PHP.ini, 因此,不是

open_basedir

将应用。

风见雨下

赞同来自:

就在您的注意事项,如果您有配置 nginx, 安装了几个 vhosts (所以配置

/etc/nginx/sites-enabled/example.com

) 然后你可能需要安装

fastcgi_param PHP_VALUE open_basedir=

那里:

    location ~ \.php$ {
try_files $uri =404;
fastcgi_param PHP_VALUE open_basedir="/var/www/:/new/path";
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;

江南孤鹜

赞同来自:

环境

open_basedir

穿过

fastcgi_param

可能会导致
https://forum.nginx.org/read.php?3,234856
当您在服务器上有几个网站时。

另一个变体 - 使用
https://www.php.net/manual/en/ ... r.php
.

要回复问题请先登录注册