1、本地的后端连接服务器的redis
后端服务的配置文件的redis地址为服务器的ip
2、服务器的后端连接同一个服务器的redis
后端服务在打包前的配置文件中redis 的地址为localhost
windows下:
1、打开redis.windows.conf文件或者redis.windows-service.conf文件,把bind 127.0.0.1注释掉,或者把它注释掉后加上bind 0.0.0.0
2、关掉守护模式,把protected-mode yes改成protected-mode no
3、设置redis密码,格式requirepass 你的密码
4、使用指定的启动文件启动redis,使用哪个文件取决于你修改了哪个文件。
redis-server.exe redis.windows.conf
或
redis-server.exe redis.windows-service.conf
Linux下:
1、修改redis.conf文件
vim redis.conf
2、Ctrl+F查找bind,注释掉bind 127.0.0.1或者把bind 127.0.0.1改成bind 0.0.0.0
bind 0.0.0.0
3、Ctrl+F查找protected-mode,把守护进程模式关掉,把protected-mode yes改成protected-mode no
protected-mode no
4、Ctrl+F查找requirepass,加上下面这句,设置密码为123456
requirepass 123456
5、启动redis
$ redis-server /path/to/redis.conf
6、远程连接测试,打开windows的命令提示符,输入 redis-cli -h 云服务器的IP -p 6379 命令,成功后输入 ping 返回ok则成功