How To Install Redis on AlmaLinux 9
In this tutorial, we will show you how to install Redis on AlmaLinux 9. For those of you who didn’t know, Redis is a popular in-memory key-value store that can be used as a NoSQL key-value database, message broker as well as a caching solution. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams. Redis is renowned for its flexibility, scalability, seamless replication, simplicity, and ease of use.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Redis on AlmaLinux 9. You can follow the same instructions for CentOS and Rocky Linux.
Prerequisites
- A server running one of the following operating systems: AlmaLinux 9.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Redis on AlmaLinux 9
Step 1. First, let’s start by ensuring your system is up-to-date.
sudo dnf clean all sudo dnf install epel-release sudo dnf update
Step 2. Installing Redis on AlmaLinux 9.
By default, Redis is available on the AlmaLinux 9 AppStream repositories. Simply run the following command to install Redis to your AlmaLinux system:
sudo dnf install redis
Next, start the Redis service and enable it to automatically start on boot by running the following command:
sudo systemctl enable redis sudo systemctl start redis sudo systemctl status redis
To verify that Redis has been installed successfully, we can run the following command:
redis-server -v
Step 3. Configure Redis.
Now we configure Redis as a cache by editing the path in the following command:
sudo nano /etc/redis.conf
You need to put the following commands at the bottom of it:
maxmemory 500mb maxmemory-policy allkeys-lru
Locate the bind parameter and replace 127.0.0.1 with 0.0.0.0:
bind 0.0.0.0
Uncomment the directive and specify your own password:
requirepass your_strong_password
Save and close the file, then restart the Redis service to apply changes:
sudo systemctl restart redis
To test if the authentication has been enabled, access the Redis client:
redis-cli
Step 4. Configure Firewall.
Open firewall ports to allow Redis incoming traffic:
sudo firewall-cmd --permanent --zone=redis --add-port=6379/tcp sudo firewall-cmd --reload
Congratulations! You have successfully installed Redis. Thanks for using this tutorial for installing Redis on your AlmaLinux 9 system. For additional help or useful information, we recommend you check the official Redis website.