WP Super Cache 网站缓存插件安装后无法启动使用

昨晚参考Dayu的博客,把网站主题由原来的Twenty twelve 改成了 Blocksy 主题。顺便安装了 WP Super Cache 网站缓存插件,提升网站打开速度。安装后启动插件,出现了如下的报错,无法使用。

wp super cache 插件报错

报错信息已经提供了问题的大致解决方案,应该是目录权限不够导致的。记录下解决步骤:

获取 wp-content 读写权限

sudo chmod 777 /var/www/html/wordpress/wp-content/

检查 cache 文件 是否存在

进入到 wp-content 目录:

cd /var/www/html/wordpress/wp-content

检查 wp-cache-config.php 是否存在?若不存在则将 ./plugins/wp-super-cache/wp-cache-config-sample.php 复制到 wp-content 中,并重命名为 wp-cache-config.php

cp plugins/wp-super-cache/wp-cache-config-sample.php ./wp-cache-config.php

检查 advanced-cache.php 是否存在?若不存在则将 ./plugins/wp-super-cache/advanced-cache.php 复制到 wp-content 中。

cp plugins/wp-super-cache/advanced-cache.php ./

然后,将两个文件都开启可写入权限。

sudo chmod 777 wp-cache-config.php advanced-cache.php

WordPress 添加配置

回到 wordpress 根目录,在 wp-config.phpABSPATH之前加入两行,激活缓存并配置WPCACHEHOME路径。

sudo vi wp-config.php
define('WP_CACHE', true);
define('WPCACHEHOME','/var/www/html/wordpress/wp-content/plugins/wp-super-cache/');

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
        define( 'ABSPATH', __DIR__ . '/' );
}

刷新 WordPress 插件页面,应该就不会报错了。但是会在 WP Super Cache 设置页面顶部提示 /var/www/html/wordpress/wp-content 权限问题,此时先不要修改权限,先启动缓存功能。

17345044536019

保存更新后再执行,修改目录权限到之前状态。

sudo chmod 755 /var/www/html/wordpress/wp-content/

搞定,收工!

留下评论

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