If your WordPress website is running slow, using a cache system like Redis can help make it much faster. Redis stores frequently used data in memory so your website doesn’t have to keep loading everything from the database every time someone visits a page. In this blog, we’ll show you How to Configure Redis Cache in a 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
#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. If you’re wondering how to configure Redis cache in a WordPress, the process is straightforward — 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 need expert assistance on how to configure Redis cache in a WordPress, our team is here to help. We specialize in server management services and can ensure a seamless configuration for better performance and faster site speeds. Contact us today to optimize your WordPress site with Redis and get the most out of your server resources.