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

  1. SSH into your server and run update commands, especially if this is a new instance
    1. sudo apt-get update
    2. sudo apt-get upgrade
  2. Install Redis Server
    1. sudo apt-get install redis-server php-redis
  3. Add or uncomment following lines to the redis.conf files at /etc/redis/redis.conf
    1. maxmemory 256mb
    2. maxmemory-policy allkeys-lfu
  4. Restart services
    1. sudo systemctl restart redis-server
    2. sudo /opt/bitnami/ctlscript.sh restart php-fpm
  5. Install php-redis extension
    1. sudo pecl install redis
  6. Update php.ini to include the new extension
    1. sudo vi /opt/bitnami/php/etc/php.ini
    2. add extension=redis.so to the file and save
  7. Restart all services
    1. sudo /opt/bitnami/ctlscript.sh restart
  8. Verify extension module is enabled
    1. php -m | grep redis
  9. Verify redis is installed and enabled
    1. redis-server --version
    2. netstat -lpan | grep :6379
  10. Install and activate redis plugin for WordPress
    1. Search for redis and install the redis object plugin
  11. Modify the wp-config.php. Add the following two lines to the wp-config. Replace domain.com with your site domain
    1. define( 'WP_CACHE_KEY_SALT', 'domain.com' );
    2. define( 'WP_CACHE', true );
  12. Enable the Object cache in the Redis plugin.
  13. Monitor Redis activity on SSH
    1. redis-cli monitor

More details can be found here