Using redis cache system can greatly optimize caching of database queries in wordpress and can have a performance boost for high traffic sites.
Here is what you need to do to install via commandline.
- Install Redis server
- Install php extension
- Install wordpress redis plugin
- SSH into your server and run update commands, especially if this is a new instance
- sudo apt-get update
- sudo apt-get upgrade
- Install Redis Server
- sudo apt-get install redis-server php-redis
- Add or uncomment following lines to the
redis.conf
files at/etc/redis/redis.conf
maxmemory 256mb
maxmemory-policy allkeys-lfu
- Restart services
sudo systemctl restart redis-server
sudo /opt/bitnami/ctlscript.sh restart php-fpm
- Install php-redis extension
- sudo pecl install redis
- Update php.ini to include the new extension
- sudo vi /opt/bitnami/php/etc/php.ini
- add
extension=redis.so
to the file and save
- Restart all services
- sudo /opt/bitnami/ctlscript.sh restart
- Verify extension module is enabled
php -m | grep redis
- Verify redis is installed and enabled
redis-server --version
netstat -lpan | grep :6379
- Install and activate redis plugin for WordPress
- Search for redis and install the redis object plugin
- Modify the wp-config.php. Add the following two lines to the wp-config. Replace domain.com with your site domain
define( 'WP_CACHE_KEY_SALT', 'domain.com' );
define( 'WP_CACHE', true );
- Enable the Object cache in the Redis plugin.
- Monitor Redis activity on SSH
redis-cli monitor
More details can be found here