插件下载地址

https://github.com/fungjcode/TpRedis

一、安装php-redis扩展

我的typecho是docker版本

在typecho容器终端里输入redis安装命令

PHP 扩展必须安装在 Typecho 容器,而不是 Redis 容器。

1️⃣ 进入容器终端

2️⃣ 安装依赖

apt-get update
apt-get install -y php-pear php-dev gcc make

3️⃣ 使用 pecl 安装 Redis 扩展

pecl install redis

安装过程中,看到如下提示时全部选择 no 即可(默认回车):

enable igbinary serializer support? [no] : 
enable lzf compression support? [no] : 
enable zstd compression support? [no] : 
enable msgpack serializer support? [no] : 
enable lz4 compression? [no] : 
use system liblz4? [yes] :

4️⃣ 启用 PHP 扩展

echo "extension=redis.so" > /usr/local/etc/php/conf.d/redis.ini

5️⃣ 重启 容器

6️⃣ 验证扩展是否生效

php -m | grep redis

输出 redis → 扩展安装成功

二、安装 Redis(服务器 + CLI)

输入安装命令

apt update
apt install -y redis-server

安装完后会自动带 redis-cli。

🟩 ③ 启动 Redis 服务

service redis-server start

或者:

redis-server --daemonize yes

检查安装是否成功:

ps aux | grep redis

输出:

redis-server 0.0.0.0:6379

🟦 ④ 测试 redis-cli 是否可用

redis-cli

成功进入后会看到:

127.0.0.1:6379>

说明 Redis 服务成功运行。

Typecho Redis 插件就可以正常使用

遇到的问题:
重启typecho docker容器后,页面上方会显示Connection Refused,重启和清空redis缓存和cdn缓存都没用

✅ 解决方法 :
进入 Typecho 容器在终端

启动 Redis:

redis-server --daemonize yes

参数说明:

--daemonize yes 会让 Redis 作为后台进程运行

默认监听 127.0.0.1:6379

然后测试:

redis-cli ping

如果返回 PONG,说明 Redis 正常运行。

最后修改:2025 年 12 月 01 日
如果觉得我的文章对你有用,请随意赞赏