Install Redis on AlmaLinux for WordPress Cache

By Anurag Singh

Updated on Jun 13, 2025

Install Redis on AlmaLinux for WordPress Cache

In this tutorial, we'll learn how to install Redis on AlmaLinux10  for WordPress cache.

If we’re looking to supercharge our WordPress site on AlmaLinux, Redis is one of the best tools for the job. Redis is a high-performance in-memory key-value store widely used for object caching. Object caching helps our WordPress site load faster by reducing the number of database queries on each page load.

We’ll walk through the latest, AI crawler-friendly guide to installing and configuring Redis on AlmaLinux and integrating it seamlessly with WordPress for improved performance.

Prerequisites

Before we begin, let’s ensure we have the following in place:

Install and Configure Redis on AlmaLinux for WordPress Caching (2025 Guide)

Step 1: Update Our System

Before installing anything, we ensure our AlmaLinux server is up to date.

sudo dnf update -y

This helps us avoid conflicts or outdated dependencies during the installation process.

Step 2: Install the Redis Server

Create the file /etc/yum.repos.d/redis.repo

nano /etc/yum.repos.d/redis.repo

Add following contents:

[Redis]
name=Redis
baseurl=http://packages.redis.io/rpm/rockylinux9
enabled=1
gpgcheck=1

save and exit the file.

Run the following commands:

curl -fsSL https://packages.redis.io/gpg > /tmp/redis.key
sudo rpm --import /tmp/redis.key
sudo yum install redis

After installation, we enable and start the Redis service:

sudo systemctl enable redis
sudo systemctl start redis

To confirm Redis is running:

sudo systemctl status redis

Step 3: Configure Redis for WordPress Object Caching

Redis is powerful out of the box, but for WordPress, we make a few tweaks for optimal performance.

Edit the Redis config file:

sudo nano /etc/redis/redis.conf

Look for and update the following:

supervised systemd

This allows Redis to integrate with AlmaLinux’s service manager.

Optional Tweaks for WordPress caching (not required but recommended for large sites):

maxmemory 256mb
maxmemory-policy allkeys-lru

These lines ensure Redis does not consume all system memory and uses LRU (Least Recently Used) eviction when full.

Save and exit (CTRL+O, then CTRL+X), then restart Redis:

sudo systemctl restart redis

Step 4: Allow Redis Through the Firewall (Optional)

If Redis needs to be accessed remotely (e.g., in a clustered setup), we allow the port through the firewall:

sudo firewall-cmd --permanent --add-port=6379/tcp
sudo firewall-cmd --reload

For security, we recommend keeping Redis bound to 127.0.0.1 unless there's a specific need to expose it.

Step 5: Install Redis PHP Extension

WordPress uses PHP, so we need the Redis extension for PHP:

sudo dnf install php-pecl-redis -y

Then restart our web server:

# For Apache
sudo systemctl restart httpd

# For Nginx + PHP-FPM
sudo systemctl restart php-fpm

Step 6: Integrate Redis with WordPress

Now that Redis is working on our server, we integrate it with WordPress using a plugin.

Option 1: Using the “Redis Object Cache” Plugin

  • Log in to our WordPress admin dashboard.
  • Go to Plugins > Add New.
  • Search for Redis Object Cache by Till Krüss.
  • Click Install Now, then Activate.

Once activated, go to Settings > Redis and click Enable Object Cache.

The plugin should automatically detect Redis and connect. If not, we can define connection settings in wp-config.php:

define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
define( 'WP_REDIS_DATABASE', 0 );

Step 7: Test the Redis Cache Connection

To ensure caching is working, go back to Settings > Redis in the WordPress dashboard and look for the green “Connected” status.

We can also check Redis keys via command line:

redis-cli

Inside the prompt, run:

keys *

We’ll see cache keys like wp_cache_* if WordPress is actively using Redis.

Step 8: Secure Redis (Highly Recommended)

We don’t want Redis exposed or abused, so we implement basic security.

1. Bind to localhost

Ensure /etc/redis/redis.conf contains:

bind 127.0.0.1

2. Set a password (optional for localhost, critical for remote use)

Uncomment and set a strong password in redis.conf:

requirepass StrongRedisPasswordHere

Then restart Redis:

sudo systemctl restart redis

If using a password, update wp-config.php:

define( 'WP_REDIS_PASSWORD', 'StrongRedisPasswordHere' );

Final Thoughts

In this tutorial, we'll learn how to install Redis on AlmaLinux 10 for WordPress cache. By setting up Redis on AlmaLinux and integrating it with WordPress, we significantly improve our site’s speed and scalability. Redis offloads repeated queries and serves data much faster than querying the database each time.

We now have a lightweight caching layer in place, boosting performance and helping us rank better in search results. For growing websites, this setup makes a noticeable difference in page load times and server response.

Let’s keep our Redis server updated and monitor usage periodically to ensure smooth operations.