VPS Series · Post 5 of 5

Redis Object Caching
on WordPress – Full Guide

Redis is an in-memory data store that caches repeated database queries so WordPress doesn't hit MySQL every page load. I've used Redis extensively for high-performance applications with complex caching requirements. Here's the full setup from scratch.

↓ DB
Load on traffic spikes
<1ms
Cache hit response time
7.0.15
Redis version installed

1 Install Redis Server

bash
apt install redis-server -y
systemctl enable redis-server
systemctl start redis-server

# Test — should return PONG
redis-cli ping

2 Install PHP Redis Extension

bash
apt install php8.3-redis -y
systemctl restart php8.3-fpm

# Verify extension is loaded
php -m | grep redis

You should see redis in the output.

3 Install WP-CLI

WP-CLI lets you manage WordPress from the terminal — essential for managing plugins and cache:

bash
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp

# Verify
wp --info --allow-root

4 Install Redis Object Cache Plugin

bash
cd /var/www/html/wordpress
wp plugin install redis-cache --activate --allow-root

The plugin is Redis Object Cache by Till Krüss — the most widely used Redis integration for WordPress with 100k+ active installs.

5 Configure wp-config.php

Add these constants above the /* That's all, stop editing! */ line:

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);

6 Enable Object Cache

bash
cd /var/www/html/wordpress
wp redis enable --allow-root

Expected output: Success: Object cache enabled.

The PHP warnings about DB_HOST already defined and HTTP_X_FORWARDED_PROTO are harmless — they come from WP-CLI running outside of HTTP context.

7 Verify It's Working

bash
# Full status check
wp redis status --allow-root

# Watch live Redis commands (browse your site while this runs)
redis-cli monitor

# Check hit/miss ratio after some traffic
redis-cli info stats | grep keyspace_hits
redis-cli info stats | grep keyspace_misses

If wp redis status shows Status: Connected and Drop-in: Valid — Redis is fully wired up and caching WordPress database queries.

That wraps up the 5-post VPS series. You now have a hardened, fast, self-hosted WordPress stack for under $8/month.