Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 带有mod_vhost_别名的动态open_basedir_Php_Apache_Open Basedir_Mod Vhost Alias - Fatal编程技术网

Php 带有mod_vhost_别名的动态open_basedir

Php 带有mod_vhost_别名的动态open_basedir,php,apache,open-basedir,mod-vhost-alias,Php,Apache,Open Basedir,Mod Vhost Alias,我正在使用mod_vhost_别名,希望为每个用户设置动态open_basedir。差不多 php_admin_value open_basedir/var/www/vhosts/%1 但它不起作用。因为我有很多虚拟主机(4000-5000),mod_宏不适合我 我正在尝试应用此修补程序 但是没有成功。有什么建议吗?可能有人会感兴趣。我已成功更改修补程序() 它使用php-5.3.10进行了测试,效果非常好。您可以使用php.ini中的选项来提供将首先执行的脚本。 在那里,您可以根据$\u服务

我正在使用mod_vhost_别名,希望为每个用户设置动态open_basedir。差不多

php_admin_value open_basedir/var/www/vhosts/%1

但它不起作用。因为我有很多虚拟主机(4000-5000),mod_宏不适合我

我正在尝试应用此修补程序


但是没有成功。有什么建议吗?

可能有人会感兴趣。我已成功更改修补程序()

它使用php-5.3.10进行了测试,效果非常好。

您可以使用php.ini中的选项来提供将首先执行的脚本。
在那里,您可以根据$\u服务器阵列的内容,通过ini\u set()函数设置open\u basedir。

是的,类似的方法可以做到:
ini\u set('open\u basedir',“/var/www/hosts/$hostname/:/tmp/”一个有用的注意事项:php不会让任何下面的
ini\u设置
来放松限制。因此,如果在前置文件中将其设置为
/var/www/html
,则会出现以下
ini\u集('open\u basedir',“/”)将不起作用。
*** main/fopen_wrappers.c       2010-04-22 01:22:31.000000000 +0300
--- main/fopen_wrappers.c       2012-03-14 17:22:49.130299133 +0200
***************
*** 145,156 ****
--- 145,168 ----
        char resolved_name[MAXPATHLEN];
        char resolved_basedir[MAXPATHLEN];
        char local_open_basedir[MAXPATHLEN];
+       char *local_open_basedir_sub; /* Substring pointer for strstr */
        char path_tmp[MAXPATHLEN];
        char *path_file;
        int resolved_basedir_len;
        int resolved_name_len;
        int path_len;
        int nesting_level = 0;
+
+       /* Special case for VIRTUAL_DOCUMENT_ROOT in the open_basedir value, which gets changed to the document root */
+       if ((strncmp(basedir, "VIRTUAL_DOCUMENT_ROOT", strlen("VIRTUAL_DOCUMENT_ROOT")) == 0) && SG(request_info).path_translated && *SG(request_info).path_translated )
+       {
+           strlcpy(local_open_basedir, SG(request_info).path_translated, sizeof(local_open_basedir));
+
+           local_open_basedir_sub=strstr(local_open_basedir,SG(request_info).request_uri);
+           /* Now insert null to break apart the string */
+           if (local_open_basedir_sub) *local_open_basedir_sub = '\0';
+
+       } else

        /* Special case basedir==".": Use script-directory */
        if (strcmp(basedir, ".") || !VCWD_GETCWD(local_open_basedir, MAXPATHLEN)) {