doujianzi8521 2014-08-27 16:16
浏览 98

WordPress - 文件(/)不在允许的路径内

I have something really strange after moving an WordPress to my Server:

Wed Aug 27 18:10:43 2014] [warn] [client 77.21.106.179] mod_fcgid: stderr: PHP Warning: is_dir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/var/www/vhosts/xyz/:/tmp/:/usr/share/pear/) in /var/www/vhosts/xyz/xyz/wp-includes/functions.php on line 1425 

Why try's WordPress to Access /? Any ideas?

While calling WordPress an 1GB Err-Log will be generated ^^

I do host around 100 WP instances, all do very well, no install trys to Access '/'.

EDIT

This is the function wich Fails:

function wp_mkdir_p( $target ) {
    $wrapper = null;

    // strip the protocol
    if( wp_is_stream( $target ) ) {
        list( $wrapper, $target ) = explode( '://', $target, 2 );
    }

    // from php.net/mkdir user contributed notes
    $target = str_replace( '//', '/', $target );

    // put the wrapper back on the target
    if( $wrapper !== null ) {
        $target = $wrapper . '://' . $target;
    }

    // safe mode fails with a trailing slash under certain PHP versions.
    $target = rtrim($target, '/'); // Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
    if ( empty($target) )
        $target = '/';

    if ( file_exists( $target ) )
        return @is_dir( $target );


    // We need to find the permissions of the parent folder that exists and inherit that.
    $target_parent = dirname( $target );

    // MY MODIFICATION
    if ($target_parent = '/') {
        var_dump($target, $target_parent);
        die(debug_print_backtrace());
    }
    // MY MODIFICATION END

    while ( '.' != $target_parent && ! is_dir( $target_parent ) ) {
        $target_parent = dirname( $target_parent );
    }

    // Get the permission bits.
    $dir_perms = false;
    if ( $stat = @stat( $target_parent ) ) {
        $dir_perms = $stat['mode'] & 0007777;
    } else {
        $dir_perms = 0777;
    }

    if ( @mkdir( $target, $dir_perms, true ) ) {

        // If a umask is set that modifies $dir_perms, we'll have to re-set the $dir_perms correctly with chmod()
        if ( $dir_perms != ( $dir_perms & ~umask() ) ) {
            $folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) );
            for ( $i = 1; $i <= count( $folder_parts ); $i++ ) {
                @chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms );
            }
        }

        return true;
    }

    return false;
}

I have added some modification, read the comments to find it, I get the following Output:

string(95) "/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/uploads/2014/09"
string(1) "/" 
#0 wp_mkdir_p(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/uploads/2014/09) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/functions.php:1743] 
#1 wp_upload_dir() called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions/other.php:360] 
#2 require(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions/other.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/template.php:503] 
#3 load_template(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions/other.php, ) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/template.php:477] 
#4 locate_template(Array ([0] => functions/other.php), 1, ) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/general-template.php:179] 
#5 get_template_part(functions/other) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions/init.php:9] 
#6 require(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions/init.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/template.php:503] 
#7 load_template(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions/init.php, ) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/template.php:477] 
#8 locate_template(Array ([0] => functions/init.php), 1, ) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/general-template.php:179] 
#9 get_template_part(functions/init) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions.php:32] 
#10 include(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-settings.php:328] 
#11 require_once(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-settings.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-config.php:111] 
#12 require_once(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-config.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-load.php:29] 
#13 require_once(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-load.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-blog-header.php:12] 
#14 require(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-blog-header.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/index.php:17] 

What is uncorrect, because dirname(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/uploads/2014/09) should return /var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/uploads/2014 and not just /...

any ideas?

  • 写回答

1条回答 默认 最新

  • dongqian0763 2015-07-14 10:50
    关注

    Double-check that the path in $target really exists. This error happened to me after moving Wordpresses from one server to another, with different internal folder setups.

    If the path in $target does not exist on your server, you need to correct every occurrence of it in the code and in the database.

    In order to safely correct the values in the database, use a tool like https://github.com/interconnectit/Search-Replace-DB that takes care of dictionary-like structures in the database.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算