Debian/Ubuntu 系统 Redis 安装部署文档
1. 更新系统包列表
bash
sudo apt update
2. 安装 Redis 服务器
bash
# 安装 Redis 服务器
sudo apt install redis-server
3. 配置 Redis
编辑 Redis 配置文件:
bash
sudo nano /etc/redis/redis.conf
修改以下关键配置项:
conf
# 绑定到所有网络接口
bind 0.0.0.0
# 关闭保护模式(允许远程连接)
protected-mode no
# 设置密码认证(推荐)
requirepass your_secure_password
4. 启动并设置开机自启
bash
# 启动 Redis 服务
sudo systemctl start redis-server
# 设置开机自启
sudo systemctl enable redis-server
# 检查服务状态
sudo systemctl status redis-server
5. 配置防火墙
bash
# 开放 Redis 默认端口
sudo ufw allow 6379/tcp
6. 重启 Redis 服务
bash
sudo systemctl restart redis-server
完成以上步骤后,Redis 服务器已经部署完成,可以通过远程客户端连接使用。