If your WordPress website is running slow, learning how to enable Redis cache in WordPress can significantly boost its performance. Redis works by storing frequently accessed data in memory, reducing the need to repeatedly load information from the database every time someone visits a page. By enabling Redis caching, you can make your site load much faster and provide a smoother experience for your visitors.
In this blog, we’ll show you how to easily set up Redis cache for your WordPress site on different Linux servers. Even if you’re not a tech expert, just follow the steps and your site will be faster in no time!
Prerequisites
- A working WordPress site
- Access to your server (SSH/root or sudo user)
- Redis server installed
- PHP Redis extension installed
- WordPress Redis plugin (like Redis Object Cache)
Step 1: Install Redis Server
On Ubuntu/Debian
#apt update
#apt install redis-server
On CentOS 7/8
#yum install epel-release
#yum install redis
On AlmaLinux 8/9
#dnf install redis
Enable and start Redis:
#systemctl enable redis
#systemctl start redis
Test Redis:
Test redis using the command:
#redis-cli ping
Output: PONG
Step 2: Install PHP Redis Extension
For PHP 8.x (All OS)
#apt install php-redis # Ubuntu/Debian
#yum install php-pecl-redis -y # CentOS
#dnf install php-pecl-redis -y # AlmaLinux
Restart your web server:
#systemctl restart apache2 # for Apache
#systemctl restart nginx # for Nginx
Step 3: Install & Enable Redis Plugin in WordPress
Log in to your WordPress Dashboard
Go to Plugins → Add New
Search for Redis Object Cache
Click Install, then Activate
Then go to:
Settings → Redis
Click Enable Object Cache
If Redis is working, you’ll see a Connected message.
Step 4: Configure wp-config.php with Redis Constants
To fine-tune Redis behavior or work with custom setups, add the following constants before the line that says /* That’s all. */ in your wp-config.php file:
// Redis Configuration
define( 'WP_REDIS_HOST', '127.0.0.1' ); // Redis server address
define( 'WP_REDIS_PORT', 6379 ); // Redis default port
define( 'WP_REDIS_PASSWORD', '' ); // Redis password if set (optional)
When should you edit these?
If Redis is hosted on another server (change WP_REDIS_HOST)
If you’re using Redis authentication (set WP_REDIS_PASSWORD)
If you’re using a different Redis database index (e.g., to isolate cache per site)
After making these changes, go back to the Redis plugin settings and flush the cache to apply.
Final Tips
Redis works best when combined with page caching plugins like LiteSpeed Cache or WP Rocket.
Monitor Redis memory usage using:
#redis-cli info memory
To flush Redis cache manually:
#redis-cli flushall
Conclusion
Setting up Redis cache for your WordPress site is a smart move to enhance speed, scalability, and overall performance. Whether you’re running on Ubuntu, CentOS, or AlmaLinux, the process is straightforward — install Redis, connect it with WordPress using a plugin, and fine-tune it through your wp-config.php file for better control.
By offloading repeated database queries to Redis, your site can handle more traffic with fewer resources, delivering a faster and smoother experience to your visitors.
If you’re unsure how to enable Redis cache in WordPress, it’s always a good idea to seek expert assistance to ensure it’s set up correctly and securely. A professional team offering reliable server management services can help you configure Redis caching, optimise your website’s performance, and handle any server-level adjustments.