How to enable Redis object cache in WordPress?

Redis object cache can improve performance for some websites that perform heavy database queries. It reduces the number of queries to the database by caching results from previous queries, resulting in faster page load times and a better user experience for some database-heavy websites and applications.

However, if your site does not need Redis, we recommend not enabling it, as it can sometimes (but not always) degrade website performance on high performance servers.

 

Secure, Isolated Redis for Multi-user Environments

Traditional Redis is insecure when used on servers with multi-user environments and shared hosting servers, as one user can easily access and modify another user's data stored in Redis.

We deploy isolated Redis instances for each user, which remain encapsulated and completely separate from other users' instances. One user cannot access or alter other users' Redis data, and one user's issues cannot impact another user's Redis instance, making it safe to use in multi-user and multi-website environments.

 

IMPORTANT!

Do not enable Redis in multiple plugins on the same website. Doing so can create conflict. If Redis is enabled in the LiteSpeed Cache for WordPress plugin, do not enable it in the Redis Object Cache plugin or any other plugin.

If you have multiple websites in the same cPanel/DirectAdmin account, specify a different "Redis Database ID" for each website to avoid key conflicts. You can set the "Redis Database ID" to any number from 0 to 7, e.g., 0 for the first website and 1 for the second, but not decimal values like 1.2. You can use a maximum of 8 databases (0 to 7) in a hosting account (cPanel/DirectAdmin account).

 

Step 1: Enable Redis in cPanel/DirectAdmin


cPanel:

Redis is integrated into the LiteSpeed Redis Cache Manager in cPanel:

  1. Go to cPanel > Redis Object Cache.

    Or, cPanel > LiteSpeed Redis Cache Manager.


  2. Click "Enable Redis Service" below "Redis Management".

    Wait for it to be enabled.

    Once enabled, a notification will appear near the top of the page saying, "Enabled Redis successful Created symlink".


  3. Done!

 

DirectAdmin:

  1. Go to DirectAdmin > Redis.

  2. Click on the toggle next to Redis to enable it.

    Once enabled, a "Success" message will appear near the bottom of the page.


  3. Done!

 

Step 2: Enable Redis PHP Extension


  1. Go to cPanel > Select PHP Version > Extensions.

    Or, DirectAdmin > Select PHP Version.


  2. Checkmark [*] redis

    Please wait 15-40 seconds to enable the Redis extension.

    Refresh the page to update its status.


  3. Done!

 

Step 3: Enable Redis in WordPress


Redis is integrated into the LiteSpeed Cache for WordPress plugin:

  1. Install LiteSpeed Cache for WordPress.

    LiteSpeed Cache is a full-page cache with native CDN integration and support for dynamic content (WooCommerce, logged-in pages, etc.). It makes your website much faster and reduces resource consumption lower than Redis, even when Redis is disabled.


  2. Go to WordPress Admin > LiteSpeed Cache > Cache > Object.


  3. Check if Redis Extension status is enabled (next to Object Cache):

    Redis Extension: Enabled

    If not enabled, complete Steps 1 and 2 above.


  4. Set "Object Cache" to ON.


  5. Set "Method" to Redis.


  6. Enter the following details:


    Host: /tmp/redis.sock
    Port: 0
    Redis Database ID: 0


    Note 1:
    Redis Database ID should be a unique number for each website.

    If you have other websites using Redis on the same hosting account (same cPanel/DirectAdmin account), the default value 0 is used for the first website.

    For the next website, set it to 1 or any value up to 7, but not 0.

    Note 2:
    Host path on DirectAdmin is different. Use the path mentioned below on DirectAdmin-based hosting accounts.


  7. Click "Save Changes".

    Connection test should now reflect the following (next to Object Cache):

    Connection Test: Passed


  8. Done!

    Redis has now been enabled.

 

Redis Socket Path on DirectAdmin


DirectAdmin uses a different path for the Redis Socket. You can view the path from DirectAdmin > Redis. You can also use the following:

Socket Path: /home/dausername/.redis/redis.sock

*Replace dausername with your DirectAdmin username.

 

  • 177 Users Found This Useful
Was this answer helpful?

Related Articles

How to install WordPress?

You can use Softaculous or WordPress Toolkit Deluxe to install and manage WordPress, depending on...

How to install LiteSpeed Cache for WordPress?

We automatically install and enable the LiteSpeed Cache for WordPress Plugin (LSCWP) on your...

How to send an email from WordPress?

You can easily send email from WordPress using SMTP. You need to create an email account and use...

How to install WP-CLI (WordPress CLI)?

You can install WordPress CLI using SSH. It can be installed without root access. If you do not...

How to change WordPress admin password?

The admin password of WordPress can be changed in multiple ways without knowing the password....