If you’ve landed here trying to figure out how to install Redis on Linux, you’re in good company. Redis is one of those tools that quietly ends up on almost every server I touch. It’s an in-memory data structure store that works as a cache, a message broker, and a session store all at once. This guide covers Ubuntu, Debian, and RHEL (plus Rocky and AlmaLinux) in one place, and it includes the kernel tuning step that most tutorials leave out. That step is the one that saves you a 2 a.m. page later.

Quick Answer
On Ubuntu/Debian, run sudo apt update && sudo apt install redis-server -y. On RHEL/Rocky/AlmaLinux, run sudo dnf install redis -y. Then enable the service, set vm.overcommit_memory = 1, disable Transparent Huge Pages, bind Redis to localhost, and add a password. The full walkthrough is below.
What Is Redis and Why Every Sysadmin Ends Up Installing It
Redis stands for Remote Dictionary Server. At its core, it keeps data in RAM, which makes reads and writes blisteringly fast. You can use it as a cache in front of a slow database, a session store for web apps, a queue, or a pub/sub message bus. It also supports rich data types like lists, sets, sorted sets, and hashes, not just plain key-value pairs.
It’s not a niche tool, either. Redis was named the top choice (42%) for AI agent memory storage in the 2025 Stack Overflow developer survey. It’s also crossed $300M in annual recurring revenue, with 50+ customers spending over $1M a year as of early 2026. People trust it with real workloads.
Get a VPS from as low as $11/year! WOW!
One important heads-up for commercial shops: Redis 8.0, released in 2025, switched to an AGPLv3 license. Versions up to 7.2 were BSD-licensed. If you’re shipping Redis inside a product, loop in whoever handles licensing before you upgrade.
Redis has been voted “Most Loved Database” in Stack Overflow’s annual developer survey for five consecutive years — a rare feat in a crowded database market.
I remember the first time I reached for Redis. I was babysitting a PHP site that stored sessions on disk, and under traffic the filesystem just couldn’t keep up. Logins crawled. I swapped sessions over to Redis on a Friday afternoon, half expecting to roll it back. Instead, page times dropped off a cliff in the best way, and I spent the weekend wondering why I hadn’t done it sooner. That site stayed quiet for years after.
Redis vs. Memcached: The One Question You Need to Answer First
Before you install anything, answer this: do you need more than a dumb-fast cache? If all you want is simple key-value caching and nothing else, Memcached is lean and fine. But the moment you need persistence, pub/sub, or complex data types, Redis wins.
Redis 8.0 benchmarks show roughly 37% higher throughput on complex workloads compared to Memcached 1.6. For straight key-value caching the two are closer. My rule of thumb: if you might need a feature beyond GET and SET later, start with Redis so you don’t migrate twice. You can dig into the details in the Redis vs Memcached official comparison.
Prerequisites
Nothing exotic here. You just need a few basics in place before you start.
- Access: root or a user with
sudoprivileges. - A supported distro: Ubuntu 22.04/24.04, Debian 11/12, or RHEL 8/9 (Rocky Linux and AlmaLinux work the same way).
- RAM: 512 MB minimum, but 1 GB or more for anything production-facing.
- Network: leave port 6379 closed in your firewall unless you genuinely need remote access. By default, bind Redis to localhost.
Install Redis on Ubuntu and Debian
You’ve got two solid paths here. The quick one uses your distro’s package manager. The recommended one pulls from Redis’s official repository so you get the latest stable release.
Option 1: Install from APT (Quick but May Not Be Latest)
This is the fastest route. The version in your distro repo may lag a release or two behind, but for most use cases it’s perfectly fine.
sudo apt update
sudo apt install redis-server -y
That’s it. The package sets up a systemd service and drops the config file at /etc/redis/redis.conf.
Option 2: Install from the Official Redis APT Repository (Recommended)
When you want the newest stable Redis, add the official repo. This adds the GPG signing key, registers the repository, then installs.
sudo apt install lsb-release curl gpg -y
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt update
sudo apt install redis -y
If GPG keys are unfamiliar territory, our guide on tuning kernel parameters with sysctl pairs well with the hardening steps later, and you’ll want both before going to production.
Install Redis on RHEL, Rocky Linux, and AlmaLinux
On the Red Hat side, Redis ships in the AppStream repository, so install is a one-liner.
sudo dnf install redis -y
If your version of RHEL hides Redis behind a module stream, enable it first:
sudo dnf module enable redis:6
sudo dnf install redis -y
A couple of distro quirks to keep in mind. The config file lives at /etc/redis/redis.conf on RHEL 8+, but older CentOS/RHEL used /etc/redis.conf. And the service name is redis here, not redis-server like on Ubuntu. That naming difference trips up more people than you’d think. For the authoritative source, keep the official Redis installation documentation open in a tab.
Start, Enable, and Verify Redis
Installing Redis doesn’t always start it or set it to launch at boot. Let’s fix both. Remember the service name difference between distro families.
# Ubuntu / Debian
sudo systemctl enable --now redis-server
# RHEL / Rocky / AlmaLinux
sudo systemctl enable --now redis
The --now flag starts the service and enables it at boot in one shot. If you want a refresher on service management, see our guide to manage services with systemctl.
Check the Service Status
Confirm Redis is actually running before you trust it.
sudo systemctl status redis-server # or 'redis' on RHEL
You want to see active (running) in green. If it’s failed, the status output usually points straight at the cause.
Test with redis-cli
The fastest sanity check in the world: ping it.
redis-cli ping
If Redis is alive, it replies PONG. That little PONG never stops being satisfying, honestly. For more detail, run redis-cli info server to see the version, OS, and uptime.
Configure Redis for Production
The defaults are fine for poking around on your laptop. They are not fine for production. Open /etc/redis/redis.conf and make these four changes.
Heads up: after every config change in this section, restart Redis with sudo systemctl restart redis-server (or redis on RHEL) for it to take effect.
Bind to the Right Interface
By default Redis should only listen on localhost. Confirm it.
bind 127.0.0.1 ::1
Never, ever bind to 0.0.0.0 on a production box without a firewall and authentication in front of it. An open Redis on the public internet gets compromised in minutes. I’ve seen the aftermath, and it’s not pretty.
Set a Memory Limit with maxmemory
Without a cap, Redis will happily eat all your RAM until the OOM killer steps in. Set a limit at roughly 75-80% of available memory.
maxmemory 256mb
Use mb or gb suffixes. On a 1 GB box, something like maxmemory 768mb leaves headroom for the OS and the fork Redis needs for snapshots.
Choose an Eviction Policy
When Redis hits maxmemory, what should it throw away? That depends on what Redis is doing for you.
- allkeys-lru: best for a pure cache — evicts the least recently used keys.
- volatile-lru: good for a session store — only evicts keys that have an expiry set.
- noeviction: for strict data stores — returns an error instead of dropping data.
maxmemory-policy allkeys-lru
Enable Persistence (Optional)
If you need data to survive a restart, Redis offers two persistence modes. RDB takes point-in-time snapshots, which are compact and fast to restore but can lose the last few minutes of writes. AOF logs every write for better durability at the cost of larger files. For a cache, you often want neither. For a session store, RDB is usually plenty. The full Redis configuration reference covers every directive if you want to go deeper.
Secure Your Redis Installation
This is where I see the most shortcuts taken, and it’s the section that matters most. A fast cache is worthless if it leaks your data.
Set a Strong Password (or Use ACLs in Redis 7+)
On older Redis, set a single password with requirepass:
requirepass your-long-random-password-here
On Redis 7 and newer, use ACLs instead. They let you create per-user permissions scoped to specific commands, key patterns, and channels.
ACL SETUSER myapp on >your-password ~* &* +@all
While you’re hardening, it’s also worth a look at how to protect your server with fail2ban to slow down brute-force attempts. You should also rename or disable dangerous commands like FLUSHALL, CONFIG, and DEBUG in production.
Firewall Rules for Port 6379
If you do need remote access, lock port 6379 down to a known subnet rather than opening it to the world.
# Ubuntu/Debian (UFW)
sudo ufw allow from 10.0.0.0/24 to any port 6379
# RHEL (firewalld)
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/24" port port="6379" protocol="tcp" accept'
sudo firewall-cmd --reload
For the full walkthrough, see how to configure UFW firewall on Ubuntu/Debian, or the equivalent firewalld rules on RHEL.
Linux Kernel Settings Redis Needs
Here’s the part most tutorials skip — and Redis literally warns you about it on startup. Two kernel settings make a real difference.
First, enable memory overcommit. Without it, the fork() Redis uses for background saves can fail on memory-constrained systems, breaking your snapshots.
echo 'vm.overcommit_memory = 1' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
Second, disable Transparent Huge Pages. THP causes nasty latency spikes when Redis allocates memory.
echo never | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
To make the THP change survive reboots, add it to a startup script or systemd unit. Our guide on tuning kernel parameters with sysctl explains how these settings persist. Trust me on these two — they’re the difference between Redis that just works and Redis that mysteriously stutters under load.
Common Errors and How to Fix Them
Even a clean install hits snags. Here are the ones I run into most, and the quick fixes.
- Address already in use: another process holds port 6379. Find it with
ss -tlnp— see our guide to check ports with the ss command. - WARNING overcommit_memory is set to 0: set
vm.overcommit_memory = 1as shown above. - WARNING Transparent Huge Pages enabled: disable THP with the
echo nevercommand. - NOAUTH Authentication required: you forgot the password. Connect with
redis-cli -a your-password. - OOM / max memory reached: raise
maxmemoryor switch your eviction policy away fromnoeviction.
I once spent an embarrassing twenty minutes on a “NOAUTH” error before realizing I’d set requirepass earlier and forgotten. Now it’s the first thing I check.
What to Build Next with Redis
Now that Redis is installed, secured, and tuned, the fun part starts. A few directions I’d point you toward:
- Session store: back your web app sessions with Redis — it pairs beautifully if you install Node.js on Linux.
- Cache layer: sit Redis in front of a relational database. Works great whether you install MySQL on Linux or install PostgreSQL on Linux.
- Pub/sub messaging: use Redis channels for lightweight real-time messaging between services.
- Local dev: spin up a throwaway instance when you run Redis in Docker.
Redis 8.0 also added io-threads for multi-threaded I/O, so if you’re chasing throughput on a busy server, it’s worth a look. And once you’re running it in production, set up log rotation with logrotate so your Redis logs don’t quietly fill the disk.
That’s the whole journey — from apt install to a hardened, production-ready cache. If this guide saved you some trouble, browse more of our Linux guides for your next build, and bookmark the site for the next time a server needs taming. Happy hacking.




