How to install Redis and enable on wordpress sites

Redis stands for Remote Dictionary Server.It’s an open-source, in-memory key-value data store.It can also be used as a database, message broker, and of course, cache. As it stores data in RAM, so its accessing speed is quite fast.

Redis cache is based on object cache. It stores data about objects that are usually requested by clients into RAM. Thus, web servers can use these data without accessing the database. This results in reduced server load and makes your site run more smoothly.

In this tutorial we’ll learn, How to install & enable redis on your wordpress site.

1. Install Redis on Your Web Server

To install Redis on CentOS , run this command:

yum install redis 

Start and enable redis service to start on system reboot as well:

systemctl start redis 
systemctl enable redis
2. Install Redis PHP Extension

Along with installing Redis, you need to install its PHP extension. This extension will allow WordPress to contact the Redis key-value store.

To install this extension, run the following command:

yum install php-pecl-redis
3. Enable Cache Settings in wp-config.php file

Next, Install “Redis Object Cache” on your wordpress site.

Next, edit the wp-config.php file to add a cache key salt with the name of your site

define('WP_CACHE_KEY_SALT', 'example.com');

Save and close the file.

NOTE: The WP_CACHE_KEY_SALT should be used when two or more WordPress sites are there & use one and the same Redis server for object caching. It avoids problem of being redirected to site A when we attempt to load site B.

4. Installing Redis Caching Plugin

Install & Activate “Redis Object Cache” plugin on your wordpress site.

After that, On your WordPress Dashboard, go to Settings > Redis > Overview . Next, click Enable Object Cache.

Now, On your webserver restart the redis service:

systemctl restart redis 

Now you’ve finished installing Redis Caching plugin on your WordPress site!

5. Verify Redis Caching on WordPress

To check if Redis cache is working well on your website or not, connect to the web server via SSH and run this command:

redis-cli monitor

The above command will show all requests handled by Redis cache on your site. Therefore, you will know what is happening to your database.

One Response to How to install Redis and enable on wordpress sites

  1. yashika says:

    Very helpful tutorial.

Leave a Reply

Your email address will not be published. Required fields are marked *