0. 下载地址

各版本下载地址:http://download.redis.io/releases,本教程使用版本为redis-5.0.4。

1. 进入应用安装目录

cd /usr/local

2. 解压安装包

tar -zxvf redis-5.0.4.tar.gz

3. 进入解压目录

cd ./redis-5.0.4

4. 执行 make 命令编译

make

注意

1) 出现"Hint:It's a good idea to run 'make test'"即为编译成功
2) 安装失败,可使用 make make distclean 命令进行安装回滚

5. 执行 make install 命令安装

make install

6. macOS系统默认将生成的可执行文件放在目录 /usr/local/bin 下

7. 备份原始 redis.conf 文件

cp redis.conf redis.conf`date +%Y%m%d%H%M%S`

8. 修改配置文件 redis.conf

修改配置文件 redis.conf 中的参数 daemonize yes ,将redis设置为已守护进程启动

9. 启动 redis 服务

redis-server ./redis.conf

10. 连接 redis 服务,并进行 Ping 测试

redis-cli -p 6379

11. 关闭 redis 服务

SHUTDOWN