pigpigpigGo

  • 最新文章🎉
  • 隐私政策🤝
  • 关于🏆
  • 友情链接🔗
帅秃顶的个人博客
  1. 首页
  2. linux
  3. 正文

使用 Redis 提升 wordpress 站点访问速度

2025年5月28日 30点热度 1人点赞 0条评论

本文使用的 linux 发行版为 debian 12,不同发行版的操作可能有所不同。

1、安装redis服务器

使用命令:

sudo apt install redis -y

安装redis服务器,安装完成后默认运行。

2、安装 redis object cache 插件

进入 wordpress 站点管理后台,在 “添加插件” 中搜索 “redis object cache”,安装对应插件。如图所示:

redis_object_cache

3、配置wp-config.php

使用 ssh 连接上 vps,切换到 wordpress 的安装目录,如 /var/www/worepress

编辑 wp-config.php 文件,找到 define( 'DB_COLLATE', '') ; 在 define( 'DB_COLLATE', ''); 后添加如下内容:
/** Redis Object Cache */
// adjust Redis host and port if necessary
define( 'WP_REDIS_CLIENT', 'credis' );
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );

// change the prefix and database for each site to avoid cache data collisions
define( 'WP_REDIS_DATABASE', 0 ); // 0-15

// reasonable connection and read+write timeouts
define( 'WP_REDIS_TIMEOUT', 0.5 );
define( 'WP_REDIS_READ_TIMEOUT', 0.3 );

保存退出后,在插件设置中启用对象缓存,成功后如图所示:

*提示:如果启用后网站提示520等类似的错误,可尝试重启apache2服务器(使用apache2服务器处理php的话)或 php-fpm ,完成后刷新。如果重启后错误仍然存在,可删除 wp-content/ 目录下的 object-cache.php 文件后刷新。

标签: debian debian12 linux redis wordpress
最后更新:2025年5月28日

帅秃顶

告别的年代,分开的理由,终不须诉说出口

点赞
< 上一篇

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复
帅秃顶 的头像
文章目录
  • 1、安装redis服务器
  • 2、安装 redis object cache 插件
  • 3、配置wp-config.php
最近评论
Avatar photo
一位 WordPress 评论者 发布于 2 个月前(04月01日) 您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravat...

COPYRIGHT © 2025 pigpigpigGo. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang