网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 生活知识 知识问答

wordpress启用redis缓存加速教程

时间:2024-11-04 06:43:32

1、首先,我们先安装服务端。1.1 服务端安装http://redis.io/download 具体版本打开开查看(提示:如果你是安装的军哥的lnmp一键安装包,请直接往下翻到1.1.1军哥lnmp安装redis)wget http://redis.googlecode.com/files/redis-2.8.19.tar.gztar xzf redis-2.8.19.tar.gzcd redis-2.8.19make #这一步之后安装就完成了。下面你可以把这几个可执行文件和redis.conf文件复制到你所希望的地方,比如我是复制到/usr/local/redis/bin 和/usr/local/redis/etc 下面的,命令如下:mkdir -p /usr/local/redis/{bin,etc,var}/bin/cp src/{redis-benchmark,redis-check-aof,redis-check-dump,redis-cli,redis-sentinel,redis-server} /usr/local/redis/bin//bin/cp redis.conf /usr/local/redis/etc/ln -s /usr/local/redis/bin/* /usr/local/bin/sed -i 's@pidfile.*$@pidfile /var/run/redis.pid@' /usr/local/redis/etc/redis.confsed -i 's@logfile.*$@logfile /usr/local/redis/var/redis.log@' /usr/local/redis/etc/redis.confsed -i 's@^dir.*$@dir /usr/local/redis/var@' /usr/local/redis/etc/redis.confsed -i 's@daemonize no@daemonize yes@'/usr/local/redis/etc/redis.confecho 'vm.overcommit_memory = 1' >> /etc/sysctl.conf sysctl -p注意,默认复制过去的redis.conf文件的daemonize参数为no,所以redis不会在后台运行,这时要测试,我们需要重新开一个终端。修改为yes则为后台运行redis。另外配置文件中规定了pid文件,log文件和数据文件的地址,如果有需要先修改,默认log信息定向到stdout。配置开机自启动redis-serverwget https://raw.githubusercontent.com/lj2007331/lnmp/master/init/Redis-server-init-CentOSmv Redis-server-init-CentOS /etc/init.d/redis-serverchmod +x /etc/init.d/redis-serverchkconfig --add redis-serverchkconfig redis-server启动redis:service redis-server start关闭redis:service redis-server stop

2、1.1军哥lnmp安装redis其实,如果大家用的是军哥的lnmp一键安装包的话,那安装就简单啦。putty进入cd /root/lnmp1.1-full/./redis.sh就两行代码!是不是很简单呢!!!安装好后,打开phpinfo.php查看。是否有如下显示的字样,有的话就是安装成功了。

wordpress启用redis缓存加速教程

3、2 客户端安装请下载下面两个文件备用将index-with-redis.php和predis.php上传到wordpress根目录。predis.php 上边工具里下载 index-with-redis.php打开index-with-redis.php编辑1.如果你正在使用cloudflare,请设置cf = 1; ,如果你想在页面上看到脚本执行时间和缓存加载时间,请设置$debug = 1。

wordpress启用redis缓存加速教程

4、如果你使用的是nginx,重命令原来的index.php为任意其它名字,把index-with-redis.php重命名为index.php。

wordpress启用redis缓存加速教程

5、如果你使用的是Apache,则需要把.htaccess中出现的index.php替换成index-with-redis.php

wordpress启用redis缓存加速教程

6、设置完后,就尽情的体验redis带来的极致流畅的速度吧!!!设置成功后左下角显示如图 说明就成功啦

wordpress启用redis缓存加速教程

7、由于格式问题可能代码无法对其,大家可以百度搜索 蓝客屋 此篇文章在里边。

© 2026 阿力知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com