Updated: 11 October 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9
CentOS 6/7 are end of life. The Redis packages on Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9 include a systemd service, so Redis starts at boot and can restart itself after a crash, without compiling or writing init scripts.
Install
# AlmaLinux / Rocky 9: Redis 7.2 (module stream) or Valkey 8 dnf module enable redis:7 && dnf install redis # or: dnf install valkey # Ubuntu 24.04 / Debian 12 apt install redis-server # or on Ubuntu 24.04: apt install valkey-server
Valkey is the community-maintained fork of Redis (after Redis changed its licence in 2024). It works as a drop-in replacement: same commands, same port 6379, same client libraries.
Start and test
systemctl enable --now redis # redis-server on Ubuntu/Debian, valkey for Valkey redis-cli ping # answers PONG (valkey-cli for Valkey)
Restart automatically after a crash
Add a systemd override: systemctl edit redis (or redis-server / valkey), then enter:
[Service] Restart=always RestartSec=3
Save, then check with systemctl show redis -p Restart. Test it by killing the process (kill -9 $(pidof redis-server)): after 3 seconds systemctl status redis shows it running again.
Secure it
- Redis listens only on 127.0.0.1 by default. Keep it that way unless another server must connect; never open port 6379 to the internet.
- If you do open it on a private network, set a password in the configuration (
requirepass, or better, ACL users) and allow the port only from those servers. - The configuration file is
/etc/redis/redis.conf(Ubuntu/Debian),/etc/redis/redis.confor/etc/redis.conf(AlmaLinux/Rocky), or/etc/valkey/valkey.conf.
Memory limit
For a cache, limit memory and let Redis remove old keys: set maxmemory 256mb and maxmemory-policy allkeys-lru, then restart.
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
