网站最近在使用Discuz架设论坛,感觉到 511yj.com主页加载速度明显下降,之前是开启了redis的,只得重新架设,很早之前整理过一篇,今天重新整理一下。
Wordpress使用Redis缓存加速|511遇见强烈推荐 | 511遇见
http://www.511yj.com/wordpress-redis-apache.html
redis下载
注意64位和32位
https://github.com/MicrosoftArchive/redis/releases
https://github.com/phpredis/phpredis/downloads
https://windows.php.net/downloads/pecl/releases/igbinary/
http://pecl.php.net/package/igbinary/1.1.1/windows
Redis在windows下的配置
1、启动没有参数配置的Redis:
(1)双击redis-server.exe
(2)在cmd命令窗口下运行redis-server或者redis-server.exe
# 示例:
Microsoft Windows [版本 6.1.7601] 版权所有 (c) 2009 Microsoft Corporation。保留所有权利。 E:\wrcold520\Redis-3.2.100-Windows-32\Redis>redis-server [6788] 10 Feb 13:47:38.750 # Warning: no config file specified, using the defaul t config. In order to specify a config file use redis-server /path/to/redis.conf [6788] 10 Feb 13:47:38.753 # Warning: 32 bit instance detected but no memory lim it set. Setting 3 GB maxmemory limit with 'noeviction' policy now. _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.504 (00000000/0) 32 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 6788 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [6788] 10 Feb 13:47:38.755 # Server started, Redis version 3.0.504 [6788] 10 Feb 13:47:38.755 * DB loaded from disk: 0.000 seconds [6788] 10 Feb 13:47:38.756 * The server is now ready to accept connections on po rt 6379
2、带配置文件启动Redis
在cmd命令窗口下运行:redis-server redis.windows.conf或者redis-server.exe redis.windows.conf
# 示例:
Microsoft Windows [版本 6.1.7601] 版权所有 (c) 2009 Microsoft Corporation。保留所有权利。 E:\wrcold520\Redis-3.2.100-Windows-32\Redis>redis-server redis.windows.conf [7540] 10 Feb 13:43:07.046 # Warning: 32 bit instance detected but no memory lim it set. Setting 3 GB maxmemory limit with 'noeviction' policy now. _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.504 (00000000/0) 32 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 7540 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [7540] 10 Feb 13:43:07.047 # Server started, Redis version 3.0.504 [7540] 10 Feb 13:43:07.048 * DB loaded from disk: 0.000 seconds [7540] 10 Feb 13:43:07.048 * The server is now ready to accept connections on po rt 6379
3、将redis加入windows服务
(1)在cmd命令窗口下运行:redis-server.exe --service-install redis.windows.conf --loglevel verbose
### 示例:
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
E:\wrcold520\Redis-3.2.100-Windows-32\Redis>redis-server.exe --service-install r
edis.windows.conf --loglevel verbose
[7776] 10 Feb 13:56:21.950 # Granting read/write access to 'NT AUTHORITY\Network
Service' on: "E:\wrcold520\Redis-3.2.100-Windows-32\Redis" "E:\wrcold520\Redis-3
.2.100-Windows-32\Redis\"
[7776] 10 Feb 13:56:21.950 # Redis successfully installed as a service.
(2)启动redis服务
在cmd命令窗口下运行:redis-server --service-start
### 示例:
E:\wrcold520\Redis-3.2.100-Windows-32\Redis>redis-server --service-start
[6780] 10 Feb 14:05:18.046 # Redis service successfully started.
(3)关闭redis服务
在cmd命令窗口下运行:redis-server --service-stop
### 示例:
E:\wrcold520\Redis-3.2.100-Windows-32\Redis>redis-server --service-stop [1660] 10 Feb 14:05:28.098 # Redis service successfully stopped.
4、移除redis的windows服务
在cmd命令窗口下运行:redis-server --service-uninstall
### 示例:
E:\wrcold520\Redis-3.2.100-Windows-32\Redis>redis-server --service-uninstall
[4744] 10 Feb 13:59:18.735 # Redis service successfully uninstalled.
5、windows下安装redis扩展
下面进行第二步:php扩展Redis功能, 下载https://github.com/nicolasff/phpredis/downloads
下载地址:
5.6 Non Thread Safe (NTS) x64
http://windows.php.net/downloads/pecl/releases/redis/2.2.7/php_redis-2.2.7-5.6-nts-vc11-x64.zip
5.6 Thread Safe (TS) x64
http://windows.php.net/downloads/pecl/releases/redis/2.2.7/php_redis-2.2.7-5.6-ts-vc11-x64.zip
还要下载igbinary的扩展包
(1) 首先,查看所用php编译版本V6/V9 在phpinfo()中查看
我的是MSVC9(Visual C++ 2008)所以下载的是 phpredis_5.4_vc9_ts.7z
(2) 将下载的php_igbinary.dll、php_redis.dll放在php扩展目录中(ext),并修改配置文件php.ini
extension=php_igbinary.dll extension=php_redis.dll
(3) 重新启动服务,查看phpinfo(),找到以下内容表示成功;
redis
Redis Support enabled
Redis Version 2.2.3
扩展下载地址:
igbinary: http://windows.php.net/downloads/pecl/releases/igbinary/1.1.1/memcache: http://windows.php.net/downloads/pecl/releases/memcache/3.0.8/
Redis在windows下的配置(在windows-64下安装redis,请参考微软redis的github:https://github.com/MSOpenTech/redis/releases)
redis.windows.conf 文件的配置(Linux中的名字叫做redis.conf)
这里推荐一篇非常详细的配置文章
redis.windows.conf配置详解 - 何其有静 - 博客园
https://www.cnblogs.com/heqiyoujing/p/9368150.html
https://blog.csdn.net/scorpio_meng/article/details/80855203