How to Set Up Redis on AlmaLinux/Rocky Linux

Redis is a popular in-memory data store commonly used for caching and session storage — this guide covers installation and basic configuration specifically on AlmaLinux/Rocky Linux.

Step 1 — Install Redis

sudo dnf install redis -y

Available directly from the base AppStream repository on current AlmaLinux/Rocky Linux versions, no additional repository needed.

Step 2 — Start and Enable Redis

sudo systemctl enable --now redis

Step 3 — Verify Redis Is Running

redis-cli ping

Should respond with PONG.

Step 4 — Configure Redis (Basic Security Hardening)

sudo nano /etc/redis/redis.conf
bind 127.0.0.1
requirepass CHANGE_ME_STRONG_PASSWORD

By default, Redis has no authentication — if any application/network path could reach it, setting a password is essential; binding to localhost only is the safest default unless genuinely needed otherwise.

Step 5 — Restart Redis to Apply Configuration

sudo systemctl restart redis

Step 6 — Testing Authenticated Access

redis-cli -a CHANGE_ME_STRONG_PASSWORD ping

Configuring firewalld (If Remote Access Is Genuinely Needed)

sudo firewall-cmd --permanent --add-port=6379/tcp --zone=internal
sudo firewall-cmd --reload

Only necessary if Redis genuinely needs to be reachable from another server — for a local application on the same VPS, localhost binding alone (without any firewall opening) is both simpler and more secure.

SELinux Considerations

See Understanding SELinux Basics on AlmaLinux/Rocky Linux — the standard Redis package installation typically works correctly with default SELinux policy; if you relocate data directories or change default ports, verify SELinux context/policy accommodates the change.

Configuring Persistence

save 900 1
save 300 10
save 60 10000

Controls how frequently Redis saves its in-memory dataset to disk — adjust based on your durability needs versus performance trade-offs (more frequent saves add some overhead).

Setting a Memory Limit

maxmemory 512mb
maxmemory-policy allkeys-lru

Prevents Redis from consuming unbounded memory; the eviction policy determines what happens when the limit is reached (LRU eviction is a common, reasonable default for cache use cases).

Connecting from an Application

npm install redis
const redis = require('redis');
const client = redis.createClient({ password: 'CHANGE_ME_STRONG_PASSWORD' });

Monitoring Redis

redis-cli info

Provides detailed statistics on memory usage, connected clients, and operation counts — useful for basic health checking and troubleshooting.

Common Errors

"NOAUTH Authentication required" errors — confirms your password protection is actually working as configured; ensure your application's connection configuration includes the correct password.

Continue Reading

Browse more articles in AlmaLinux & Rocky Linux.

  • redis almalinux, redis rocky linux installation, redis requirepass security, redis rhel setup
  • 0 brukere syntes dette svaret var til hjelp
Var dette svaret til hjelp?

Relaterte artikler

AlmaLinux vs Rocky Linux vs CentOS: What Happened to CentOS?

If you're choosing a RHEL-compatible Linux distribution for your VPS, understanding the CentOS...

How to Get Started with AlmaLinux/Rocky Linux on a VPS

This guide covers the essential first steps after deploying a new AlmaLinux or Rocky Linux VPS...

How to Use dnf: The Package Manager for AlmaLinux & Rocky Linux

dnf (Dandified YUM) is the package manager for AlmaLinux, Rocky Linux, and other RHEL-family...

How to Configure firewalld on AlmaLinux/Rocky Linux

firewalld is the default firewall management tool on AlmaLinux and Rocky Linux, using a...

How to Install Nginx on AlmaLinux/Rocky Linux

This guide covers installing and configuring Nginx on AlmaLinux or Rocky Linux, including the...