phpstudy为例
第一步:查看phpstudy版本
nginx+php5.6 nts
第二步:查看phpinfo信息,看Architecture所属类型.(这一步很重要,要安装自己合适的)
Compiler MSVC9 (Visual C++ 2008)
Architecture x86
PHP Extension Build API20121212,TS,VC11
第三步:下载redis扩展
https://pecl.php.net/package/redis
根据Thread Safety disabled 判断下载的是nts 还是ts
第四步:4、拷贝文件到phpstudy安装目录下的 php5\ext 文件夹下:
php_redis.dll
php_redis.pdb
5、在php.ini 文件下添加配置
extension=php_igbinary.dll
extension=php_redis.dll
注意:php_igbinary.dll 在前
6、重启phpstudy查看phpinfo();
7、redis服务启动
安装后测试会发现server went away,服务未开启
需要在windows端下载安装Redis服务
下载地址 https://github.com/MicrosoftArchive/redis/releases
自行选择版本安装(压缩文件)
说是安装,只要选择个磁盘解压即可
使用命令行cmd 切换到自己解压文件夹目录下,运行 redis-server.exe redis.windows.conf
测试可用
$redis = new \Redis();
$redis->connect('127.0.0.1',6379);
$redis->set('dada','helloworld');
echo $redis->get("dada");
但开发过程中Redis手动开启是不切合实际,应该设置在服务中启动
开启cmd窗口,切换到redis解压文件夹目录下,运行 redis-server --service-install redis.windows.conf
红框表示已成功成为服务
在cmd框中输入 services.msc 打开所有服务列表,找到Redis服务,自行启动该服务
如果想重启Redis:
net stop redis
net start redis
卸载redis服务
cmd redis-server.exe --service-uninstall
如果要修改最大存储文件大小,可修改redis.windows.conf文件中的maxmemory
如果要设置密码,可修改redis.windows.conf文件中的requirepass
记得重启服务
以上,感谢https://blog.csdn.net/qq_40784783/article/details/80610426(原文出处)