Redis安装

安装 Redis 的步骤因操作系统而异,以下是常见平台的安装方法:

Linux (Ubuntu/Debian)

  1. 更新软件包列表:

    sudo apt update
  2. 安装 Redis:

    sudo apt install redis-server
  3. 启动 Redis 服务:

    sudo systemctl start redis-server
  4. 设置开机自启:

    sudo systemctl enable redis-server
  5. 检查运行状态:

    sudo systemctl status redis-server

Linux (CentOS/RHEL)

  1. 添加 EPEL 仓库(如未安装):

    sudo yum install epel-release
  2. 安装 Redis:

    sudo yum install redis
  3. 启动并启用 Redis:

    sudo systemctl start redis
    sudo systemctl enable redis

macOS (通过 Homebrew)

  1. 安装 Redis:

    brew install redis
  2. 启动 Redis:

    brew services start redis  # 后台运行

    或手动运行:

    redis-server

Windows

Windows 官方不支持原生 Redis,但可以通过以下方式:

  1. Windows Subsystem for Linux (WSL)
    在 WSL 中按上述 Linux 步骤安装。

  2. 微软维护的 Redis 移植版
    下载地址:https://github.com/microsoftarchive/redis/releases
    (注意:非官方最新版,仅用于开发测试)。


验证安装

连接到 Redis 并测试:

redis-cli ping

如果返回 PONG,说明 Redis 正常运行。

基本配置

  • 配置文件路径(Linux): /etc/redis/redis.conf

  • 允许远程访问(需谨慎):修改 bind 127.0.0.1 为 0.0.0.0 并设置密码 requirepass yourpassword

卸载 Redis

  • Ubuntu/Debian:

    sudo apt remove --purge redis-server
  • macOS:

    brew uninstall redis
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值