2

我目前open_basedir restriction在 Media Temple 上运行的 CakePHP 应用程序出现错误。(出于提问的目的更改了站点编号和域)。

我在这里阅读了文档:https ://kb.mediatemple.net/questions/514/How+do+I+set+the+path+for+open_basedir%3F#gs了解如何解决此问题。

我在我的 php.ini 文件中尝试了以下内容:

open_basedir = /home/00000/domains

但仍然得到同样的错误。如下:

Warning (2): file_exists(): open_basedir restriction in effect. File(/home/00000/domains/test.com/html/app/webroot/index.php/img/cameron.jpg) is not within the allowed path(s): (/home/00000/domains) [APP/Plugin/Timthumb/Vendor/timthumb.php, line 896]

有任何想法吗?

肯定会应用更改,因为错误路径已更新为我上面指定的内容,但我仍然受到open_basedir限制。并且做 phpinfo() 也显示了变化:

在此处输入图像描述

更新:Media Temple 对此不提供支持,但礼貌地提供了一些帮助,并表示我需要执行以下操作:

open_basedir = "/home/00000/data/tmp:/home/00000/domains"

但是,这仍然不起作用!他们无法提供进一步的信息。

更新 2:Mod_rewrite 已启用,我正在使用此插件:https ://github.com/vishal-logiciel/TimthumbPlugin/

4

2 回答 2

2

该问题看起来与您正在使用的框架无关 - 引发错误的供应商类不依赖于任何(相关)外部配置。

存在配置或应用程序错误

但这不是open_basedir设置。(只要它包含/home/00000/domains/test.com/html/应该没问题)。

引发错误的文件正在尝试访问(正确)导致问题的路径:

Warning (2): file_exists(): open_basedir restriction in effect. 

File(/home/00000/domains/test.com/html/app/webroot/index.php/attachments/view/5)
                                                   ^^^^^^^^^

is not within the allowed path(s): (/home/00000/domains) 
[APP/Plugin/Timthumb/Vendor/timthumb.php, line 896

路径与文件冲突,即使打开的基本目录允许它也不可能是读/写路径。

找出原因

使用的基本路径来自服务器变量- 它是否包含index.php?:

protected function calcDocRoot(){
    $docRoot = @$_SERVER['DOCUMENT_ROOT'];
    if (defined('LOCAL_FILE_BASE_DIRECTORY')) {
        $docRoot = LOCAL_FILE_BASE_DIRECTORY;   
    }   
    if(!isset($docRoot)){ 
        $this->debug(3, "DOCUMENT_ROOT is not set. This is probably windows. Starting search 1.");
        if(isset($_SERVER['SCRIPT_FILENAME'])){
            $docRoot = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF'])));
            $this->debug(3, "Generated docRoot using SCRIPT_FILENAME and PHP_SELF as: $docRoot");
        }   
    }   
    if(!isset($docRoot)){ 
        $this->debug(3, "DOCUMENT_ROOT still is not set. Starting search 2.");
        if(isset($_SERVER['PATH_TRANSLATED'])){
            $docRoot = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF'])));
            $this->debug(3, "Generated docRoot using PATH_TRANSLATED and PHP_SELF as: $docRoot");
        }   
    }   
    if($docRoot && $_SERVER['DOCUMENT_ROOT'] != '/'){ $docRoot = preg_replace('/\/$/', '', $docRoot); }
    $this->debug(3, "Doc root is: " . $docRoot);
    $this->docRoot = $docRoot;
}

如果index.php不是来自docRoot值 - 它在传递的参数$src中。确定$src包含无效路径的原因或方式,并适当地更正应用程序代码。

于 2014-03-06T23:27:19.587 回答
2

您应该在 open_basedir 中留下最后的尾随 '/'。根据文档:

当您想限制对指定目录的访问时,以斜杠结尾。例如:open_basedir = /dir/incl/

因此,您的条目仅适用于 /home/00000/domains,而不适用于任何子目录。

于 2014-03-04T00:46:12.940 回答