准备环境
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插件 并启用
编辑wp-config.php添加以下内容,需在最后10行前添加内容,请根据实际情况修改
/*redisip地址*/
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