在Debian12系统搭配宝塔面板运行WordPress,并启用Object Cache Pro插件时,不少用户可能会遭遇一些棘手的问题。今天就来详细讲讲这些问题以及对应的解决办法。
遭遇的问题
问题1
当尝试启用Object Cache Pro时,出现如下错误提示:
“An object cache error has occurred: Failed to initialize object cache: PhpRedis was not compiled with igbinary support. 'For more information about enabling serializers see: https://objectcache.pro/docs/data-encoding/'”
这表明PhpRedis在编译时未包含igbinary支持,而Object Cache Pro需要该支持才能正常初始化对象缓存。
问题2
另一个常见错误是:
“An object cache error has occurred: Failed to initialize object cache: PhpRedis was not compiled with Zstandard compression support, see For more information about enabling compressions see: https://objectcache.pro/docs/data-encoding/”
此错误意味着PhpRedis编译时缺少Zstandard压缩支持,同样影响Object Cache Pro的正常初始化。
解决办法
1. 安装编译工具(只需一次)
首先要确保系统具备编译所需的工具,通过以下命令进行安装:
apt update
apt install -y gcc make autoconf libtool pkg-config git
这些工具为后续编译扩展提供必要的环境支持。
2. 处理igbinary支持
- 下载igbinary源码:进入
/root
目录,克隆igbinary仓库:
cd /root
git clone https://github.com/igbinary/igbinary.git
cd igbinary
- 使用宝塔PHP 8.0的phpize生成配置:
/www/server/php/80/bin/phpize
- 配置、编译与安装:
./configure --with-php-config=/www/server/php/80/bin/php-config
make && make install
完成这一系列操作后,igbinary扩展就安装好了,为PhpRedis提供了igbinary支持。
3. 处理Zstandard压缩支持
- 安装zstd开发库:通过命令安装zstd开发库:
apt install -y libzstd-dev
4.编译phpredis并启用zstd + igbinary
- 下载phpredis源码:同样在
/root
目录下克隆phpredis仓库,默认拉取的是最新版(支持igbinary),若有指定版本需求,也可通过git checkout
指定版本,如git checkout 6.0.3
:
cd /root
git clone https://github.com/phpredis/phpredis.git
cd phpredis
- 再次使用宝塔PHP 8.0的phpize生成配置:
/www/server/php/80/bin/phpize
- 清理并重新配置编译phpredis并启用zstd + igbinary:
cd /root/phpredis
make clean
./configure \
--with-php-config=/www/server/php/80/bin/php-config \
--enable-redis-igbinary \
--enable-redis-zstd
- 编译并安装:
make -j$(nproc) && make install
5. 重启PHP并验证
最后一步,重启PHP服务以应用新安装的扩展:
/etc/init.d/php-fpm-80 restart
完成上述所有步骤后,再次检查WordPress中Object Cache Pro的运行状态,应该就能正常使用,不再出现之前的错误。
在服务器环境配置过程中,遇到问题不可怕,只要按照正确的方法逐步解决,就能让WordPress在Debian12和宝塔面板下稳定高效地运行Object Cache Pro,提升网站性能。