Installation: update source and download redis service
#进入 root用户下
#apt-get update
#apt-get install redis-server
Do you want to continue? [Y/n]
Y
Test whether it can be used
#redis-cli
ping一下
redis 127.0.0.1:6379> ping
PONG
127.0.0.1:6379> exit
Setting login password
#vi /etc/redis/redis.conf
Then it is recommended to search to find the following comment
#requirepass foobared
Click the letter i of the English keyboard to enter the editing mode
Remove the hash sign, and change foobared to the redis login password you want to set For
example: I want to set the password to jamkung
requirepass jamkung
Save and exit
左上角Esc键
Shift 和 : 同时按下
输入 wq 并回车
Allow remote login
PS: Note that if your host is Alibaba Cloud and Tencent Cloud, pay attention to whether your server opens the corresponding port 6379. Generally, set it in the security group. According to your own host Baidu or Google how to open it, otherwise even if the host allows it Remote login, the port is not allowed or can not log in
By default, redis can only log in locally and not log in remotely, so modify the settings
修改文件
# vi /etc/redis/redis.conf
按一下英文键盘 i 字母进入编辑模式
找到下面这行 加上# 取消绑定本地
#bind 127.0.0.1
保存并退出
左上角Esc键
Shift 和 : 同时按下
输入 wq 并回车
Restart redis to load configuration
# service redis-server restart
Remote access commands
# redis-cli -h (空格) (redis的ip 地址,可以写域名) -p (空格) (redis的端口号 如果默认是6379可以不用写这个端口) -a (空格) (密码,如果没有可以不用写这参数)