WordPress配置Redis缓存
准备环境
Redis
安装请参考:https://freexyz.cn/database/98271.html
php安装redis扩展
[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++