Skip to content

部署 Redis 服务器

Redis 是有 C 编写的跨平台程序。我们所谓的安装 Redis 通常就是部署 redis 服务器。官方推荐在 Linux 上进行部署。

Linux 下安装

所有的主流 Linux 发行版仓库都内置了 Redis 的特定版本,可以直接使用包管理器来安装:

Bash
sudo apt install redis

之后通常还需要启动下服务:

Bash
# 启动
sudo systemctl start redis

# 开启启动
sudo systemctl enable redis

最后我们可以使用 redis-cli 来连接查看:

Bash
$ redis-cli
127.0.0.1:6379> ping
PONG

从源码安装

发行版内置仓库中的版本如果太老也可以从源码来构建:

Bash
# 下载
wget https://download.redis.io/redis-stable.tar.gz

# 解压编译
tar -xzvf redis-stable.tar.gz
cd redis-stable
make

# 安装
sudo make install

# 启动服务,也可以自己编写 systemd unit 来管理
redis-server

参考