Redis is a high-performance, in-memory data store widely used for caching, session management, real-time analytics, and message brokering. Starting with Rocky Linux 10, the distribution replaced Redis with Valkey in the AppStream repository. Valkey is an open source fork created after Redis changed its license to the non-FOSS Server Side Public License (SSPL), and it maintains full compatibility with Redis commands and protocols, so existing applications and configurations work without modification.
Choose Your Installation Method
Before proceeding, decide which package best fits your needs. The following table compares the available installation methods across Rocky Linux versions:
| Method | Rocky Version | Package | Version | Best For |
|---|---|---|---|---|
| Valkey (DNF) | Rocky 10 | Valkey | 8.0.x | Most Rocky 10 users who want the default FOSS-compatible option |
| Redis (AppStream) | Rocky 9 | Redis | 6.2.x | Stability-focused servers on Rocky 9 |
| Redis (AppStream) | Rocky 8 | Redis | 5.0 or 6.0 | Stability-focused servers on Rocky 8 |
| Redis (Remi RPM) | Rocky 8, 9, 10 | Redis | 7.2 through 8.4 | Users who specifically need Redis rather than Valkey |
For Rocky Linux 10 users, Valkey is recommended because it ships in the default AppStream repository, requires no third-party configuration, and maintains full Redis protocol compatibility. Meanwhile, Rocky Linux 8 and 9 users can rely on the AppStream Redis packages for a stable, distro-tested version. Only install Redis from Remi if you have a specific requirement for Redis itself or need a newer version than AppStream provides.
These instructions cover Rocky Linux 8, 9, and 10. Commands work identically across versions unless noted otherwise, with version-specific steps clearly marked where the installation method differs.
Update Rocky Linux Before Installation
Before installing any new software, update your system packages to ensure you have the latest security patches and dependency versions. This step helps prevent conflicts during installation.
sudo dnf upgrade --refresh
This command refreshes the repository metadata and then upgrades all installed packages to their latest versions. If updates seem slow, you can optimize DNF performance on Rocky Linux by enabling fastestmirror and parallel downloads.
Method 1: Install Valkey on Rocky Linux 10 (Recommended)
Valkey is available in the default Rocky Linux 10 AppStream repository and provides the same functionality as Redis. However, Rocky Linux 10 does not include Redis compatibility symlinks, so you will use the valkey-cli and valkey-server commands directly rather than the traditional redis-cli and redis-server commands.
Install Valkey
To install Valkey, run the following command:
sudo dnf install valkey -y
This command installs the Valkey server and CLI tools. After the installation completes, you can use valkey-cli to connect to the server and valkey-server to manage the daemon.
Verify Valkey Installation
Next, confirm the installation succeeded by checking the Valkey server version:
valkey-server --version
Expected output:
Valkey server v=8.0.6 sha=00000000:1 malloc=jemalloc-5.3.0 bits=64 build=27677fdfb54cc97
Enable and Start Valkey Service
After installation, Valkey does not start automatically. Enable the service and start it immediately:
sudo systemctl enable valkey --now
The --now flag starts the service immediately while also enabling it for automatic startup on boot. Next, verify that Valkey is running:
systemctl status valkey
Expected output:
● valkey.service - Valkey persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/valkey.service; enabled; preset: disabled)
Active: active (running) since Fri 2026-01-10 12:00:00 UTC; 5s ago
Main PID: 1234 (valkey-server)
Tasks: 5 (limit: 23141)
Memory: 7.5M
CPU: 45ms
CGroup: /system.slice/valkey.service
└─1234 /usr/bin/valkey-server 127.0.0.1:6379
This output confirms the service is active and running, listening on the default port 6379.
Test Valkey Connection
Additionally, verify the server responds to commands by connecting with the CLI and sending a PING command:
valkey-cli ping
Expected output:
PONG
A PONG response confirms the server is accepting connections and functioning correctly. You can now skip to the Configure Valkey or Redis section to customize your installation.
Method 2: Install Redis from AppStream (Rocky 8 and 9)
The AppStream repository provides Redis versions that the Rocky Linux team has tested for stability and compatibility. However, this method works only on Rocky Linux 8 and 9; it is not available on Rocky Linux 10, which uses Valkey instead.
Install Redis on Rocky Linux 9
Rocky Linux 9 provides Redis through the AppStream repository using module stream 7, which delivers Redis 6.2.x. First, check the available Redis module streams:
dnf module list redis
Expected output:
Rocky Linux 9 - AppStream Name Stream Profiles Summary redis 7 common [d] Redis persistent key-value database Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
To install Redis using the default stream, run:
sudo dnf install redis -y
Install Redis on Rocky Linux 8
Rocky Linux 8 provides Redis 5.0 as the default stream, with Redis 6.0 available as an alternative. Check the available streams:
dnf module list redis
Expected output:
Rocky Linux 8 - AppStream Name Stream Profiles Summary redis 5 [d] common [d] Redis persistent key-value database redis 6 common [d] Redis persistent key-value database Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
To install Redis 6 instead of the default Redis 5, enable the stream first:
sudo dnf module enable redis:6 -y
sudo dnf install redis -y
Alternatively, install the default Redis 5 without enabling a specific stream:
sudo dnf install redis -y
Enable and Start Redis Service
After installation, Redis does not start automatically. Enable the service and start it immediately:
sudo systemctl enable redis --now
Next, verify that Redis is running:
systemctl status redis
Expected output:
● redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; preset: disabled)
Active: active (running) since Fri 2026-01-10 12:00:00 UTC; 5s ago
Main PID: 1234 (redis-server)
Tasks: 5 (limit: 23141)
Memory: 7.2M
CPU: 45ms
CGroup: /system.slice/redis.service
└─1234 /usr/bin/redis-server 127.0.0.1:6379
Confirm the installed version:
redis-server -v
Expected output (Rocky Linux 9 AppStream):
Redis server v=6.2.20 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=564f77c428d6e8ab
Next, test the connection by sending a PING command:
redis-cli ping
Expected output:
PONG
A PONG response confirms Redis is accepting connections. You can now skip to the Configure Valkey or Redis section to customize your installation.
Method 3: Install Redis from Remi Repository
The Remi repository provides the latest stable Redis releases, including versions 7.2, 8.0, 8.2, and 8.4. Consequently, this method is available on all Rocky Linux versions and is useful when you specifically need Redis rather than Valkey, or when you need a newer Redis version than AppStream provides.
Note: On Rocky Linux 10, installing Redis from Remi will conflict with Valkey. If you have Valkey installed, remove it first with
sudo dnf remove valkeybefore proceeding.
Install EPEL and Remi Repository on Rocky Linux 10
First, install EPEL (Extra Packages for Enterprise Linux), then add the Remi repository:
sudo dnf install epel-release -y
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-10.rpm -y
If you see a warning about modularity being deprecated on Rocky Linux 10, this is expected behavior as DNF5 transitions away from the module system. The Redis module installation still works correctly.
Install EPEL and Remi Repository on Rocky Linux 9
On Rocky Linux 9, enable CRB (CodeReady Builder) first, as some EPEL packages depend on it. Then install EPEL and Remi:
sudo dnf config-manager --set-enabled crb
sudo dnf install epel-release -y
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm -y
See our guide to install EPEL on Rocky Linux for detailed setup instructions. Additionally, our Remi RPM installation guide provides comprehensive repository information.
Install EPEL and Remi Repository on Rocky Linux 8
Rocky Linux 8 uses PowerTools instead of CRB. Enable it before installing EPEL and Remi:
sudo dnf config-manager --set-enabled powertools
sudo dnf install epel-release -y
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
If you receive an error that
config-manageris not found, install thednf-plugins-corepackage first:sudo dnf install dnf-plugins-core -y
View Available Redis Versions
After adding the Remi repository, list the available Redis module streams to see all version options:
dnf module list redis
Expected output (Rocky Linux 10):
Remi's Modular repository for Enterprise Linux 10 - x86_64 Name Stream Profiles Summary redis remi-7.2 common [d] Redis persistent key-value database redis remi-8.0 common [d] Redis persistent key-value database redis remi-8.2 common [d] Redis persistent key-value database redis remi-8.4 common [d] Redis persistent key-value database Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
Expected output (Rocky Linux 9 with Remi):
Remi's Modular repository for Enterprise Linux 9 - x86_64 Name Stream Profiles Summary redis remi-5.0 common [d] Redis persistent key-value database redis remi-6.0 common [d] Redis persistent key-value database redis remi-6.2 common [d] Redis persistent key-value database redis remi-7.0 common [d] Redis persistent key-value database redis remi-7.2 common [d] Redis persistent key-value database redis remi-8.0 common [d] Redis persistent key-value database redis remi-8.2 common [d] Redis persistent key-value database redis remi-8.4 common [d] Redis persistent key-value database Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
Similarly, Rocky Linux 8 with Remi shows the same streams as Rocky Linux 9.
Enable and Install Your Chosen Redis Version
Enable the Redis module stream you want to install. For the latest version (Redis 8.4):
sudo dnf module enable redis:remi-8.4 -y
Alternatively, choose a different version based on your requirements:
# For Redis 7.2 (stable, widely supported)
sudo dnf module enable redis:remi-7.2 -y
# For Redis 8.0
sudo dnf module enable redis:remi-8.0 -y
After enabling the module stream, install Redis:
sudo dnf install redis -y
Next, enable and start the Redis service:
sudo systemctl enable redis --now
Then verify the installation by checking the version:
redis-server -v
Expected output (Redis 8.4):
Redis server v=8.4.0 sha=00000000:0 malloc=jemalloc-5.3.0 bits=64 build=f7fadcec9189b92
Finally, confirm the service is running correctly:
systemctl status redis
Additionally, you can verify the server is listening on the expected port:
ss -tlnp | grep 6379
Expected output:
LISTEN 0 511 127.0.0.1:6379 0.0.0.0:* users:(("redis-server",pid=2345,fd=6))
Use the Command Line Interface
Both Valkey and Redis provide an interactive command-line interface for working with your database. After installation, you can connect, store data, and run diagnostic commands directly from the terminal.
Connect to the Server
Open an interactive session. For Valkey on Rocky Linux 10:
valkey-cli
For Redis on Rocky Linux 8 or 9:
redis-cli
You should see the server prompt:
127.0.0.1:6379>
Test Basic Operations
First, test the connection with a ping command:
PING
Expected output:
PONG
Next, store a key-value pair:
SET greeting "Hello from Rocky Linux"
Expected output:
OK
Then retrieve the stored value:
GET greeting
Expected output:
"Hello from Rocky Linux"
Afterward, delete a key:
DEL greeting
Expected output:
(integer) 1
Finally, you can view all keys in the database (use cautiously on production systems with many keys):
KEYS *
When finished, exit the CLI:
QUIT
If you plan to use Valkey or Redis with PHP applications like WordPress, Laravel, or custom web apps, you will also need to install PHP on Rocky Linux and enable the php-redis extension for your PHP version.
Configure Valkey or Redis
Both Valkey and Redis use similar configuration files with the same directive syntax. However, the configuration file location differs depending on which package you installed.
Configuration File Locations
First, open the configuration file with your preferred text editor:
For Valkey (Rocky Linux 10):
sudo nano /etc/valkey/valkey.conf
For Redis (Rocky Linux 8, 9, or Remi installation):
sudo nano /etc/redis/redis.conf
Set Maximum Memory Limit
By default, Valkey and Redis use as much memory as needed. For production systems, set a memory limit to prevent the server from consuming all available RAM. Find the maxmemory directive and set an appropriate value:
# Set maximum memory to 512 MB
maxmemory 512mb
Common memory values include 256mb, 512mb, 1gb, or 2gb. Therefore, choose based on your server’s available RAM and workload requirements.
Configure Cache Eviction Policy
When the server reaches the memory limit, it needs an eviction policy to decide which keys to remove. The policy depends on your use case:
- allkeys-lru: Evict the least recently used keys from all keys. Best for general caching.
- volatile-lru: Evict the least recently used keys that have an expiration set. Use when you mix cache data with persistent data.
- allkeys-lfu: Evict the least frequently used keys. Better than LRU for some workloads.
- noeviction: Return errors when memory limit is reached. Use for data that must not be lost.
Based on your use case, set the eviction policy in the configuration file:
# Use LRU eviction for general caching
maxmemory-policy allkeys-lru
Configure Network Binding
By default, Valkey and Redis only listen on localhost (127.0.0.1), which is the safest configuration. To allow connections from specific IP addresses, modify the bind directive:
# Listen on localhost and a specific internal IP
bind 127.0.0.1 192.168.1.100
Security warning: Binding to all interfaces (
bind 0.0.0.0) exposes the server to the network. Unauthenticated Valkey and Redis instances have been exploited in numerous security incidents, including cryptojacking attacks. Port 6379 is frequently scanned by attackers looking for unsecured instances. Always configure password authentication and firewall rules before exposing the server to a network.
Set Password Authentication
Protect your installation with a password to prevent unauthorized access. Find the requirepass directive and set a strong password:
# Set a strong password (use a random string in production)
requirepass YourStrongPasswordHere
After setting a password, clients must authenticate before running commands. Without authentication, the server returns:
(error) NOAUTH Authentication required.
To connect with password authentication using the CLI:
# Valkey
valkey-cli -a YourStrongPasswordHere
# Redis
redis-cli -a YourStrongPasswordHere
The server displays a warning when you pass the password on the command line with
-a: “Using a password with ‘-a’ option on the command line interface may not be safe.” For production systems, consider setting the password in an environment variable or using theAUTHcommand after connecting.
Alternatively, you can authenticate after connecting:
AUTH YourStrongPasswordHere
Expected output on successful authentication:
OK
Apply Configuration Changes
After modifying the configuration file, restart the service to apply changes:
For Valkey:
sudo systemctl restart valkey
For Redis:
sudo systemctl restart redis
Verify the service restarted successfully by checking its status. For more configuration options, consult the official Valkey documentation or Redis documentation.
Configure Firewall Rules
If you need to access Valkey or Redis from other machines on your network, configure firewalld to allow connections on port 6379. These rules are only necessary when the server is bound to a network interface beyond localhost.
Allow the Service Port
The simplest approach is to use the built-in Redis service definition, which also works for Valkey since both use port 6379:
sudo firewall-cmd --permanent --zone=public --add-service=redis
sudo firewall-cmd --reload
Allow Only Specific IP Addresses
For better security, restrict access to specific IP addresses using rich rules. This allows connections only from trusted servers:
sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.1.100" port protocol="tcp" port="6379" accept'
sudo firewall-cmd --reload
Allow an IP Range
Alternatively, to allow an entire subnet (for example, all machines on 192.168.1.0/24):
sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" port protocol="tcp" port="6379" accept'
sudo firewall-cmd --reload
Verify Firewall Configuration
Afterward, confirm that the rule was applied:
sudo firewall-cmd --list-all
Expected output (showing redis service enabled):
public (active) target: default icmp-block-inversion: no interfaces: eth0 sources: services: cockpit dhcpv6-client redis ssh ports: protocols: forward: yes masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
Test connectivity from a remote allowed host:
# Valkey
valkey-cli -h 192.168.1.50 ping
# Redis
redis-cli -h 192.168.1.50 ping
Replace 192.168.1.50 with your server’s IP address. A successful connection returns PONG.
Troubleshoot Common Issues
Service Fails to Start
If the service fails to start after configuration changes, check the journal for error messages:
# Valkey
sudo journalctl -xeu valkey
# Redis
sudo journalctl -xeu redis
A common error is a syntax mistake in the configuration file:
valkey.service: Main process exited, code=exited, status=1/FAILURE valkey-server[1234]: Bad directive or wrong number of arguments
Test the configuration file for syntax errors by running the server manually. It reads the configuration and reports any errors before attempting to start:
# Valkey
valkey-server /etc/valkey/valkey.conf
# Redis
redis-server /etc/redis/redis.conf
If the configuration is valid but you want to exit without starting the server, press Ctrl+C immediately after verifying no errors appear. If there are syntax errors, the server displays specific error messages indicating the problematic line:
*** FATAL CONFIG FILE ERROR *** Reading the configuration file, at line 42 >>> 'maxmemory-policy invalid_policy' Bad directive or wrong number of arguments
After fixing any errors in the configuration file, restart the service.
Cannot Connect from Remote Host
If you cannot connect from another machine, verify the following:
First, check that the server is listening on the expected interface:
ss -tlnp | grep 6379
If the output shows only 127.0.0.1:6379, the server is bound to localhost only. Update the bind directive in the configuration file to include the network interface you want to use.
Then verify the firewall allows connections:
sudo firewall-cmd --list-services --zone=public | grep redis
Finally, test connectivity from the remote machine:
redis-cli -h 192.168.1.100 -p 6379 ping
Memory Warning at Startup
The server may log warnings about memory overcommit settings:
WARNING overcommit_memory is set to 0! Background save may fail under low memory condition.
To resolve this warning, enable memory overcommit. This setting applies immediately:
sudo sysctl vm.overcommit_memory=1
Make the change persistent across reboots:
echo "vm.overcommit_memory = 1" | sudo tee -a /etc/sysctl.conf
Module Conflict Between AppStream and Remi
If you encounter errors about conflicting module streams when trying to install from Remi after previously using AppStream, reset the module first:
sudo dnf module reset redis -y
sudo dnf module enable redis:remi-8.4 -y
sudo dnf install redis -y
Remove Valkey or Redis
If you no longer need the installation, follow the appropriate steps for your installed package.
Remove Valkey (Rocky Linux 10)
First, stop the service and remove the packages:
sudo systemctl stop valkey
sudo dnf remove valkey -y
sudo dnf autoremove -y
Warning: The following command permanently deletes all Valkey data files. Back up your data first if needed:
sudo cp -r /var/lib/valkey ~/valkey-backup
If desired, you can also remove configuration and data files:
sudo rm -rf /etc/valkey /var/lib/valkey /var/log/valkey
Then, verify the removal by checking that the command is no longer available:
which valkey-server
Expected output:
/usr/bin/which: no valkey-server in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
This output confirms that Valkey has been completely removed from your system.
Remove Redis (AppStream or Remi)
First, stop the service and remove the packages:
sudo systemctl stop redis
sudo dnf remove redis -y
sudo dnf autoremove -y
Additionally, if you installed from the Remi repository and want to reset the module stream:
sudo dnf module reset redis -y
Warning: The following command permanently deletes all Redis data files. Back up your data first if needed:
sudo cp -r /var/lib/redis ~/redis-backup
If desired, you can also remove configuration and data files:
sudo rm -rf /etc/redis /var/lib/redis /var/log/redis
Finally, verify the removal by checking that the command is no longer available:
which redis-server
If Redis is removed, this command produces no output or shows “no redis-server” message.
Conclusion
You now have a working Valkey or Redis installation on Rocky Linux with memory limits, authentication, and firewall rules configured. Rocky Linux 10 users benefit from Valkey’s open source license while maintaining full Redis protocol compatibility. Rocky Linux 8 and 9 users can choose between stable AppStream packages or newer versions from the Remi repository. To build a complete web application stack, consider pairing your installation with PHP and Nginx for session caching and performance optimization.
Useful Links
For further reading, these resources provide additional information and documentation:
- Valkey Official Website: Documentation, installation guides, and command reference for Valkey.
- Valkey Documentation: Detailed guides on data types, configuration, and best practices.
- Redis Official Website: Information about the original Redis project and documentation.
- Redis Documentation: Comprehensive Redis command reference and configuration guides.
- Remi’s RPM Repository: Repository providing Redis and PHP packages for Rocky Linux and other RHEL-based distributions.