Why Use Redis for WordPress?
WordPress executes numerous database queries on every page load. Redis stores frequently accessed data in memory, eliminating redundant database calls and reducing page load times significantly. On a Breeze, this can cut response times by 50% or more for dynamic pages.
Prerequisites
- A Breeze running Ubuntu 22.04+ with WordPress installed
- PHP 8.0+ with the phpredis extension
- Root or sudo access
Step 1: Install Redis Server
sudo apt update
sudo apt install redis-server php-redisStep 2: Configure Redis
sudo nano /etc/redis/redis.confSet these recommended values:
maxmemory 256mb
maxmemory-policy allkeys-lru
supervised systemdsudo systemctl restart redis-server
sudo systemctl enable redis-serverStep 3: Install the Redis Object Cache Plugin
Install and activate the Redis Object Cache plugin from the WordPress dashboard under Plugins > Add New. Then navigate to Settings > Redis and click Enable Object Cache.
Step 4: Verify the Connection
Check Redis is accepting connections:
redis-cli pingYou should see PONG. Monitor cache activity in real time:
redis-cli monitorAdvanced Configuration
Add these constants to wp-config.php for fine-tuning:
define('WP_REDIS_HOST', '127.0.0.1');
define('WP_REDIS_PORT', 6379);
define('WP_REDIS_DATABASE', 0);
define('WP_REDIS_PREFIX', 'wp_');Tips
- Monitor memory usage with
redis-cli info memory - Use separate Redis databases if running multiple WordPress sites on your Breeze
- Restart PHP-FPM after installing the phpredis extension