windows下安装redis,为开发提供便利

安装redis客户端

地址,选择msi格式的安装文件

更改密码

找到redis目录下的redis.windows.confredis.windows-service.conf文件,编辑,搜索# requirepass foobared在后面添加一下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands. This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared
requirepass 123456
# Command renaming.
#
# It is possible to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# hard to guess so that it will still be available for internal-use tools
# but not available for general clients.

重启redis服务

windows使用win+R键,输入services.msc,找到redis,点击重启服务

下载32位 PHP7.0版本的拓展驱动

1.redis驱动:https://pecl.php.net/package/redis

2.igbinary驱动:https://windows.php.net/downloads/pecl/releases/igbinary/

将拓展复制到php\ext
然后在php.ini 增加拓展,重启Apache服务器即可

1
2
extension=php_igbinary.dll
extension=php_redis.dll

在PHP里面设置

端口默认是6379

1
2
3
4
5
6
7
8
return [
........
'redis' =>[
'host' => '127.0.0.1',
'port' => 6379,
'password' => '123456',
]
]