2.13.1.2.5. Setting up Redis in WordPress

So that WordPress can use Redis, you need to install and configure one of the specialized plugins.

  1. Openup Adminpanel site.
  2. Install and activate the plugin Redis Object Cache.
  3. Edit config file site wp-config.php and add to its beginning right after <?php such lines (in the second line instead of example substitute title the hosting account in which the site is hosted, in the third — instead of example substitute a unique prefix for storing data in Redis, which is important when using Redis for multiple sites):
    define('WP_REDIS_SCHEME', 'unix');
    define('WP_REDIS_PATH', '/home/example/.system/redis.sock');
    define('WP_CACHE_KEY_SALT', 'example');
  4. In the admin panel of the site, go to the section "Settings → Redis" and press "Enable Object Cache":If everything is in order, at the top of the section opposite "Condition" should display "Connected":
  5. Check the site is working.
  1. Openup Adminpanel site.
  2. Install and activate the plugin W3 Total Cache.
  3. Go to section "Performance → General Settings":
  4. In the block "Object Cache":
    1. Against "Object Cache" check the box next to "Enabled".
    2. Against "Object Cache Method" choose "Redis".
    3. Save your changes.
  5. Go to section "Performance → Object Cache":
  6. In the block "Advanced":
    1. Against "Redis hostname:port / IP:port" indicate /home/example/.system/redis.sock (insteadof example substitute hosting account namewhere the site is located) and click "Test":If everything is in order, a green inscription should be displayed "Test passed":
    2. Save your changes.
  7. Follow the same steps for "Page Cache" and "Database Cache".
  8. Check the site is working.

Paid plugin

You can purchase a license for official website.
  1. Openup Adminpanel site.
  2. Install and activate the Object Cache Pro plugin (installation is performed either by downloading the archive with the plugin through the WordPress admin panel, or by manually placing the plugin directory in the WordPress plugin directory).
  3. Place the plugins directory in the WordPress plugins directory.
  4. Edit config file site wp-config.php and add lines like this to it (in the second line, instead of <your-license-token> substitute your license token, in the third line — instead of example substitute title hosting account that hosts the site):
    define('WP_REDIS_CONFIG', [
        'token' => '<your-license-token>',
        'host' => 'unix:///home/example/.system/redis.sock',
        'database' => 0, // change for each site
        'maxttl' => 86400 * 7,
        'timeout' => 1.0,
        'read_timeout' => 1.0,
        // 'prefetch' => true,
        // 'split_alloptions' => true,
        'debug' => false,
    ]);
     
    define('WP_REDIS_DISABLED', false);
  5. In the WordPress dashboard, find the widget "Object Cache Pro" and press "Enable Object Cache"... If everything is in order, it should be highlighted "Status: Connected".
  6. Check the site is working.

Connection Redis by using Redis Object Cache and W3 Total Cache:

Content