wordpress迁移服务器后WP Super Cache 错误:Warning! WP Super Cache caching broken! The script advanced-cache.php could not load wp-cache-phase1.php

Warning! WP Super Cache caching broken! The script advanced-cache.php could not load wp-cache-phase1.php.

Please edit /var/www/html/ and make sure the path to /var/www/html/wp-content/plugins/wp-super-cache/wp-cache-phase1.php is correct.

把整个wordpress打包压缩迁移到新的服务器上后,发现后台里出现这样的一条错误消息,以前根本没有的。清理wp super cache缓存,都不行。查了官方的FAQ,仔细查看了一下文件wp-content/advanced-cache.php 发现问题所在了,文件内容如下

<?php
# WP SUPER CACHE 0.8.9.1
function wpcache_broken_message() {
if ( false == strpos( $_SERVER[ 'REQUEST_URI' ], 'wp-admin' ) )
echo "<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->";
}
if ( !include_once( '/home/xxxxx/www/html/wp-content/plugins/wp-super-cache/' . 'wp-cache-phase1.php' ) ) {
if ( !@is_file( '/home/xxxxx/www/html/wp-content/plugins/wp-super-cache/' . 'wp-cache-phase1.php' ) ) {
define( 'ADVANCEDCACHEPROBLEM', 1 );
register_shutdown_function( 'wpcache_broken_message' );
}
}
?>

文件内容红色加粗部分(如果你看不到红色或加粗,请到这里来看http://www.path8.net/tn/archives/4342 ),就是wp-cache-phase1.php文件的路径,错的,是之前老服务器上的路径,自然是无法引用到文件的。修改为相对新服务器正确的路径的,保存完成。

顺便说一句,wp super cache的开发人员在这里没有使用相对路经(或带前缀常量的路径表示文件wp-cache-phase1.php的路径),所以整站迁移服务器后,路径就错了。如可以写成if ( !include_once( "{$const_wp_root}/wp-content/..... 这样的形式就可避免该问题;可能是因为各种原因,是这样写不方便,所以才直接写绝对路径了。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据