Install Redis on Rocky Linux 8/9
If you’re on a Rocky Linux box—be it the newer EL9 or the trusty EL8—and you need an in‑memory store, this is how to get Redis up and running without chasing endless repositories or ending up with a half‑configured service.
Why bother?
Redis is the go‑to caching layer for web apps, job queues, and real‑time analytics. On Rocky Linux it’s not hidden behind a proprietary repo; you can pull it straight from EPEL (for EL9) or the official Remi stream (for EL8). The result: a lightweight service that starts in seconds and plays nicely with systemd.
1. Update the system
sudo dnf update -y
You may think “just run it anyway,” but an old kernel or outdated packages can bite you later when Redis tries to bind to its default port (6379) or when SELinux refuses to allow writes to /var/lib/redis. Updating first gives you a clean slate.
2. Enable the right repos
On EL9
sudo dnf install -y epel-release
EPEL already contains Redis 7 for EL9, so no extra hassle.
On EL8
# Install the Remi repo that ships with Redis 6.x or newer sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm # Enable the module stream for Redis sudo dnf module reset redis sudo dnf module enable redis:remi-stable
I’ve seen people try to dnf install redis on EL8 and end up with a 5.x build that can’t parse some of the newer configuration syntax. Enabling the Remi stream pulls in the latest stable version.
3. Install Redis
sudo dnf install -y redis
That’s all, folks. The package brings in redis-server, a systemd unit file (redis.service), and a sample config under /etc/redis.conf.
4. Fine‑tune the configuration
Open /etc/redis.conf:
sudo nano /etc/redis.conf
- Bind to localhost or your LAN interface?
By default it’s bound only to 127.0.0.1. If you need external clients, change bind 127.0.0.1 ::1 to the desired IP.
- Set a password (recommended for anything beyond local dev). Find the line that starts with # requirepass and remove the hash, then add your secret:
requirepass mysupersecret
- Persist data?
If you want Redis to snapshot or append‑only files on disk, make sure save lines are active. For a pure cache, leave them commented out.
Why bother editing these bits? Because the default config is tuned for local demos. Real deployments—especially ones exposed to the internet—should lock down access and enable persistence if you care about data durability.
5. Start and enable the service
sudo systemctl start redis sudo systemctl enable redis
systemctl status redis should show an “active (running)” state. If it fails, check /var/log/redis/redis-server.log; mis‑configurations often surface there.
6. Test the installation
redis-cli ping
You should see PONG. Try setting a key:
redis-cli set foo bar redis-cli get foo
You’ll receive bar. If that works, you’re good to go.
Gotchas I’ve seen
- SELinux blocking writes – On EL9 with SELinux enforcing, the default /var/lib/redis may not have the right context. A quick fix is:
sudo semanage fcontext -a -t redis_db_t "/var/lib/redis(/.*)?" sudo restorecon -Rv /var/lib/redis
- Firewall issues – If you exposed Redis to other machines, remember to allow port 6379 in firewalld:
sudo firewall-cmd --permanent --add-port=6379/tcp sudo firewall-cmd --reload
7. (Optional) Secure it further
If your server is reachable over the internet, consider setting up a redis.conf snippet that requires clients to authenticate and uses TLS. The community has solid guides on enabling TLS in Redis 6+. Don’t skip this step unless you’re running a closed‑network dev box.
That’s it: a fresh Redis instance on Rocky Linux 8 or 9, ready for caching, pub/sub, or any other use case that demands lightning‑fast key/value storage.