1.安装步骤:
redis最新下载地址:https://redis.io/download
$ wget http://download.redis.io/releases/redis-4.0.9.tar.gz $ tar xzf redis-4.0.9.tar.gz $ cd redis-4.0.9 $ make
make时如报有如下错误
cd src && make all make[1]: Entering directory `/usr/local/redis-4.0.9/src' CC adlist.o /bin/sh: cc: command not found make[1]: *** [adlist.o] Error 127 make[1]: Leaving directory `/usr/local/redis-4.0.9/src' make: *** [all] Error 2
是因为没安装gcc,Redis是C实现的,所以需要gcc来进行编译
apt install gcc
安装完后再运行make命令
2.设置远程连接
vim redis.conf
找到bind 127.0.0.1并注释
#bind 127.0.0.1
protected-mode修改为no
protected-mode no
找到 # requirepass foobared
取消注释,并设置自己的密码
保存,然后启动
cd src/
./redis-server ../redis.conf
停止命令
./redis-cli -h 127.0.0.1 -p 6379 shutdown