准备环境

Redis

安装请参考:https://www.ym68.cc/linux/2020/011225.html

php安装redis扩展
[root@php-server ~]# yum -y install gcc make
[root@php-server ~]# curl -o redis-5.2.1.tgz http://pecl.php.net/get/redis-5.2.1.tgz
[root@php-server ~]# tar xf redis-5.2.1.tgz -C /usr/src/
[root@php-server ~]# cd /usr/src/redis-5.2.1/
[root@php-server redis-5.2.1]# /usr/local/php7/bin/phpize 
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
[root@php-server redis-5.2.1]# ./configure --with-php-config=/usr/local/php7/bin/php-config 
[root@php-server redis-5.2.1]# make &&make install
/usr/local/php7/lib/php/extensions/no-debug-non-zts-20180731/
[root@php-server redis-5.2.1]# vim /usr/local/php7/php.ini
extension=ext/redis
[root@php-server ~]# phpd restart

安装配置Redis Object Cache插件

安装WP插件Redis Object Cache 并启用

编辑wp-config.php添加以下内容,需在最后10行前添加内容,请根据实际情况修改

/*redis主机IP地址*/
define('WP_REDIS_HOST', '10.152.98.1');
/*redis端口*/
define('WP_REDIS_PORT', '10300');
/*连接的数据库ID*/
define('WP_REDIS_DATABASE', '0');
/*redis键值前缀*/
define('WP_CACHE_KEY_SALT', 'blog_');
/*key密钥*/
define('WP_REDIS_PASSWORD', 'Uxas_d5#S%');
/*键值过期时间*/
define('WP_REDIS_MAXTTL', '86400');

点击Enable Object Cache开启redis连接并缓存


开启状态

遇到的问题

1.没有PHP_AUTOCONF参数
[root@php-server redis-5.2.1]# /usr/local/php7/bin/phpize 
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

解决方法

yum -y install autoconf
2.没有安装gcc
[root@php-server redis-5.2.1]# ./configure --with-php-config=/usr/local/php7/bin/php-config 
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... no
checking for gcc... no
configure: error: in `/usr/src/redis-5.2.1':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

解决方法

yum -y install gcc gcc-c++
END

本文标题:WordPress配置Redis缓存

本文作者:宇宙最帅的男人

本文链接:https://lolicp.com/linux/20211546.html

版权声明:转载或者引用本文内容请注明来源及原作者,本文著作权归作者 (宇宙最帅的男人) 所有。

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

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