Redis (Remote Dictionary Server) as a fast in memory key-value data store is a popular object cache solution for WordPress. Main benefit of using it is a reduced workload for the database server as most of the frequent and repeated database queries are served directly from the object cache. While the object cache may not give any performance boost for small, static or mostly cached websites, it certainly is a game changer for dynamic high traffic websites such as e-commerce stores.
This guide will help you to install and properly configure newest Redis version on your Almalinux 8/9 VPS or dedicated server.
Redis Installation on AlmaLinux
First log in into the Linux terminal of your VPS or Dedicated server with root privileges because you will need to execute a couple of commands.
Enable REMI Repository
In order to get the newest Redis version you must first enable REMI repository. Default AlmaLinux repository contains older releases, but I recommend using the newest possible one (currently Redis 8) as it will include significant performance improvements and several new user-facing features.
Use the following command according to your AlmaLinux version in order to install / enable REMI repository:
For AlmaLinux 8
sudo dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
For AlmaLinux 9
sudo dnf install http://rpms.remirepo.net/enterprise/remi-release-9.rpm -y
Check for available Redis versions
By running this command you can see what Redis versions are available for installation on your server. You can run this to ensure that you will install the latest – most up to date version of Redis:
dnf module list redis
Output should look like this:

From which we see that the Redis version 8.0 from Remi’s repository is the latest one.
Installing Redis from REMI Repository
To install a newest version of Redis from the REMI repository, you must use the following command (will work on all AlmaLinux versions). Replace the X.X part with the newest version number you see in the list from running the previous command:
sudo dnf module install redis:remi-X.X -y
e.g. to install Redis 8.0, you must use a command:
sudo dnf module install redis:remi-8.0 -y
However if the installation fails with an error similar to this:
The operation would result in switching of module ‘redis’ stream ‘remi-X.X’ to stream ‘remi-Y.Y’
Error: It is not possible to switch enabled streams of a module unless explicitly enabled via configuration option module_stream_switch.
Use the following commands to reset the redis module, enable and install the version you specifically want. Again this is for installing Redis 8.0. If you need a different version, modify the version number in the code to your needs:
sudo dnf module reset redis -y
sudo dnf module enable redis:remi-8.0 -y
sudo dnf install redis -y
Enable & Startup Redis after installation
As the last step to finish with default configuration, use this command to enable & startup redis as a service immediately:
sudo systemctl enable --now redis
Enable the use of Unix Sockets for REDIS
1. Instruct Redis to use Unix sockets for connection with the web server – Unix Sockets in almost every case are up to 50% faster than TCP sockets over the loopback interface.
Edit the Redis configuration file by opening it in a VI editor by using this command (according to your AlmaLinux version):
AlmaLinux 8
vi /etc/redis.conf
AlmaLinux 9
vi /etc/redis/redis.conf
type in /unixsocket to quickly navigate to the configuration parameters you’ll need to change and press on the INSERT key to start editing the file. Uncomment the two “unixsocket” and “unixsocketperm” parameters and adjust their values to the following:
unixsocket /var/run/redis/redis.sock
unixsocketperm 770
When done press ESC key and exit the VI editor by typing :wq in the console and pressing the ENTER key.
2. Adjust the default permissions for the Redis socket file – this is necessary to solve the permissions problem for the redis socket file on a Plesk server. Without this fix you cant use Plesk in your websites via Unix sockets.
Edit the Redis service configuration file by opening it in a VI editor:
vi /etc/systemd/system/redis.service.d/limit.conf
Press the INSERT key to start editing the file and add the following line under the [Service] section:
Group=psacln
After that press ESC key, type :wq in the console and press ENTER to exit VI editor
3. Restart the Redis to apply all of the changes
systemctl daemon-reload
systemctl restart redis
Enable memory over-commit on the server
According to official Redis documentation and this article, allowing the operating system to allocate more memory for apps than physically available is almost a requirement when configuring the server for Redis. This is necessary for avoiding unnecessary system failures, optimizing Redis performance and mitigating low memory problems on the server. To do this, just type these commands in the console and reboot the server afterwards (reboot is OPTIONAL – just to check if settings have been applied permanently):
sysctl vm.overcommit_memory=1
echo "vm.overcommit_memory=1" >> /etc/sysctl.conf
To check if the settings has been applied use this command after a reboot:
cat /proc/sys/vm/overcommit_memory
Set Transparent Huge Pages to madvise
This is also a popular Redis configuration tweak to avoid any negative impact on Redis memory usage and latency. An important thing is to set Transparent Huge pages to “madvise”. You will find a lot of guides which recommends to completely disable Transparent Huge pages, but do not follow that advice since it is long outdated now.
To check the current status of Transparent Huge Pages you can use the following commands:
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
A safest and most reliable way to set the Transparent Huge Pages to “madvise” is by creating a system service for this operation, so first let’s start with creating a file for that. Start by executing this command:
vi /etc/systemd/system/madvise-thp.service
Then press an INSERT key and paste these contents into the file:
[Unit]
Description=Set Transparent Huge Pages to madvise
After=network.target
[Service]
Type=oneshot
ExecStart=/bin/bash -c "echo madvise > /sys/kernel/mm/transparent_hugepage/enabled"
[Install]
WantedBy=multi-user.target
After this press ESC key, type in :wq in the console and press ENTER to exit the VI editor. Enable and start the newly created service by using these following commands:
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable madvise-thp.service
sudo systemctl start madvise-thp.service
After this, double check if everything is running properly by running the same cat commands I mentioned before:
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
How to uninstall Redis from Almalinux server
This is just for informative purposes. Uninstallation of Redis is simple – To uninstall it from your AlmaLinux server, use the following commands:
sudo systemctl disable redis
sudo systemctl stop redis
sudo dnf remove redis -y
It is sufficient to use only the last command, but I added the additional two for extra safety.
Useful tools for Redis management
Redis Insight
URL: https://redis.com/redis-enterprise/redis-insight/
Redis Insight is basically a graphical user interface for managing Redis databases. You can connect it to Redis server directly or via the SSH tunnel which is a great option when you run Redis locally on your VPS / Dedicated server with no accessible ports from outside. I’ve used this tool to oversee the databases, Redis performance and sometimes locating the correct databases when I’ve lost their mapping.
FAQ about installing and configuring Redis Object Cache
Read more about Redis
Fix for Filesystem not writeable error in WordPress Redis Object Cache plugin