使用Redis给WordPress缓存加速

前段时间听人说redis对网站加速效果很好,于是想试试,把博客原先的,Memcached替换成redis试试

首先当然是安装redis 我是直接apt-get 安装一下,或者编译安装,这个网上教程一大堆就不啰嗦了,安装完成以后,我是卸载了Memcached,然后把 /wp-content   目录的插件删除 ,/wp-content 目录下的插件都是 Drop-in高级插件,小心使用,然后安装完成以后,需要安装插件,在插件安装里面搜索一下 redis ,我用的是WP Redis 貌似用的人挺多,而且更新也比较多,安装完毕启用即可,然后  说明中有写 一般情况就

  1. Install object-cache.php to wp-content/object-cache.php with a symlink or by copying the file.

把/wp-content/plugins/wp-redis里的object-cache.php拷贝到/wp-content  目录下即可 就会自己开始redis缓存了

顺便贴一下 redis 的配置

bind 127.0.0.1

protected-mode yes

port 6379

tcp-backlog 511

timeout 0

tcp-keepalive 300

daemonize yes

supervised no

pidfile /var/run/redis_6379.pid

loglevel notice

logfile ""

databases 16

always-show-logo yes

save 900 1
save 300 10
save 60 10000

stop-writes-on-bgsave-error yes

rdbcompression yes

rdbchecksum yes

dbfilename www_moenyi_cn_dump.rdb

dir /www/backup/

replica-serve-stale-data yes

replica-read-only yes

repl-diskless-sync no

repl-diskless-sync-delay 5

repl-disable-tcp-nodelay no

replica-priority 100

lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no

appendonly no

appendfilename "appendonly.aof"

appendfsync everysec

no-appendfsync-on-rewrite no

auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

aof-load-truncated yes

aof-use-rdb-preamble yes

lua-time-limit 5000

slowlog-log-slower-than 10000

slowlog-max-len 128

latency-monitor-threshold 0

notify-keyspace-events ""

hash-max-ziplist-entries 512
hash-max-ziplist-value 64

list-max-ziplist-size -2

list-compress-depth 0

set-max-intset-entries 512

zset-max-ziplist-entries 128
zset-max-ziplist-value 64

hll-sparse-max-bytes 3000

stream-node-max-bytes 4096
stream-node-max-entries 100

activerehashing yes

client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

dynamic-hz yes

aof-rewrite-incremental-fsync yes

rdb-save-incremental-fsync yes

 

 

 

去主页看看把 ,你要是再尾部或者什么的地方写了 那个啥来着 一下叫不出来了,统计页面加载时间和数据库查询时间的那个,就可以看到 数据库查询次数基本就是个位数