适用版本:
运行环境:windows 7 X64
php版本:5.5.X
配置步骤:
1、安装 redis 到指定位置(Redis-x64-2.8.2103.msi),比如:C:\apache_mysql_php\redis
2、将 php_redis.dll 和 php_igbinary.dll 文件拷贝到 /php/ext 文件夹
3、修改 php.ini 文件:添加下述语句(注意添加顺序)
extension=php_igbinary.dll
extension=php_redis.dll
测试配置是否成功:
1、打开CMD
2、进入 redis 安装目录
3、输入命令:redis-server.exe redis.windows.conf
4、配置成功显示如下:
5、常见错误截图如下:
解决方法:
根据提示,是 maxheap 标识有问题,打开配置文件 redis.windows.conf ,搜索 maxheap , 然后直接指定好内容即可。
# maxheap <bytes>
maxheap 1024000000
redis客服端测试:
1、设置redis服务客户端
在CMD输入命令:>C:\apache_mysql_php\redis\redis-cli.exe -h localhost -p 6379(登录redis服务)
2、测试key->value
用 PHP 测试
Php代码
$redis = new Redis();//初始化$redis->connect("localhost","6379"); //php客户端设置的ip及端口//存储一个 值$redis->set("say","Hello World");echo $redis->get( "say" ); //应输出Hello World
//存储多个值$array = array('first_key'=>'first_val',
'second_key'=>'second_val','third_key'=>'third_val');
$array_get = array('first_key','second_key','third_key');$redis->mset($array);
var_dump($redis->mget($array_get));
在Windows上以服务方式运行 Redis
1、运行 RedisWatcher.msi,(默认安装在C:\Program Files\RedisWatcher)
2、修改 watcher.conf 文件(主要修改红色标记的地方)
[
# required exepath and exename are combined to form full path
exepath c:\apache_mysql_php\redis # redis-server.exe 安装路径exename redis-server.exe
# optional fastfailMS is milliseconds after which failure is not failure to start (default 1000)
#fastfailMS 1000
# optional fastfailretries is number of times to retry if failure before fastfailMS (default 0)
#fastfailretries 0
# for each instance to run, put properties between '{' and '}' lines
# required workingdir is working directory for process - must be unique
# optional runmode may be 'console' or 'hidden'
# optional cmdparms is command line after exename (ex: cmdparms redis.conf)
# optional saveout is '1' or '0'. To save stdout to file use '1'.
{
workingdir c:\apache_mysql_php\redis # redis-server.conf 安装路径runmode hiddensaveout 1cmdparms redis.windows.conf # redis-server.conf 配置名称
}
#{
# workingdir c:\redis\inst2
#runmode hidden
#saveout 1#cmdparms redis.conf
#}
]