Redis 安装
在 Linux / macOS / Windows 上安装并启动 Redis。
Key PointsLinux 用 apt/yum 装 redis-server;macOS 用 brew;Windows 用 WSL 或微软移植版。
Linux
Shell
sudo apt install -y redis-server # Debian/Ubuntu
sudo systemctl enable --now redis-serverOutput
Created symlink ...redis-server.service
Active: active (running)macOS
Shell
brew install redis
brew services start redisOutput
(redis) successfully startedWindows
There is no official native Windows build; use WSL (install Ubuntu, then install as on Linux). A legacy Microsoft port (Redis 3.x) exists for local learning only.
验证启动
Shell
redis-cli pingOutput
PONGredis-cli ping returning PONG means the server is alive. A fresh instance has no password and may bind 0.0.0.0 — a public Redis with no auth is a major risk; set requirepass before production.Linux
Shell
sudo apt install -y redis-server # Debian/Ubuntu
sudo systemctl enable --now redis-serverOutput
Created symlink ...redis-server.service
Active: active (running)macOS
Shell
brew install redis
brew services start redisOutput
(redis) successfully startedWindows
官方不支持原生 Windows,推荐用 WSL(wsl install Ubuntu 后按 Linux 方式装)。也有微软维护的旧版移植(Redis 3.x),仅适合本地学习。
验证启动
Shell
redis-cli pingOutput
PONGredis-cli ping 返回 PONG 说明服务端活着。新装实例默认无密码且监听 0.0.0.0,暴露在公网极危险——上生产前务必设 requirepass 并限制绑定地址。