1.查看当前php环境

打开phpinfo();
搜索Architecture (x64|x86) #x86是32位 x64是64位
搜索Thread Safety (enabled|disabled) #enabled是TS版本,disabled是NTS版本
搜索PHP Extension Build (API20131226,TS,VC11) #api版本,VC11是编译器版本


根据图上配置信息,我们需要找的php扩展就是php 5.6 VC11ts-x64

2.下载php_redis.dll

地址一:https://pecl.php.net/package/redis/2.2.7/windows

地址二:https://windows.php.net/downloads/pecl/releases/redis/2.2.7/

3.文件及配置

将下载的文件解压,然后复制php_redis.dll到C:\wamp\bin\php\php5.6.31\ext
然后编辑apache的php.ini扩展C:\wamp64\bin\apache\apache2.4.27\bin

extension=php_redis.dll

重启wamp后到phpinfo()中查看

4.php连接并测试redis数据库

<?php  
 $redis = new Redis();  
 $redis->connect('127.0.0.1',6379);   
 $redis->set('year','2018');  
 echo $redis->get('year');  
?>  

Redis 安装

下载地址:https://github.com/MSOpenTech/redis/releases

打开一个 cmd 窗口 使用cd命令切换目录到 C:\redis 运行 redis-server.exe redis.windows.conf

这时候另启一个cmd窗口,原来的不要关闭,不然就无法访问服务端了

切换到redis目录下运行 redis-cli.exe -h 127.0.0.1 -p 6379
设置键值对 set year 2018
取出键值对 get year

参考链接:http://blog.csdn.net/leesin2011/article/details/72801629

作者 铁血 汉子 2018年3月10日
2024/04/26/11:09:28am 2018/3/10/6:16:14
0 4561