The first time a WordPress page is loaded a database query is made via PHP. When using Redis, these queries can be stored in system memory so that when another user loads the same page there is no need to query the database again. Redis will retrieve the previously cached query results from memory. Setting this will help improve WordPress performance. To get started with enabling Redis with WordPress support, please continue below: The first thing is to have a working WordPress site. If you don’t have WordPress installed, then search our site for help installing WordPress. We have covered WordPress installation with both Apache2 and Nginx support on this site.

How to install the latest Redis server on Ubuntu Linux

After installing WordPress, run the commands below to install the latest version of Redis. The version of the Redis server that comes with Ubuntu by default isn’t the latest. To install the latest version you will have to add the PPA below and install from there. To do that, run the commands below: Once that package is installed, run the commands below to add the PPA that contains the latest version of Redis. After adding the repository, run the command below to install Redis. Verify that you have version 4 of Redis installed with the following command: You should see the Redis version installed on your system.

How to set up the Redis eviction policy

Now that Redis is installed, run the commands below to open its configuration file. Then uncomment the lines below to allow memory and an eviction policy. You’ll have to scroll through the lines to find these. Then set them up as shown below: Save the file and exit. When you’re done run the commands below restart Redis and PHP. If you’re running Apache2, then just restart Apache2 and the Redis server.

How to configure WordPress with Redis

After the above steps run the commands below to open the WordPress wp-config.php file in your WordPress root directory. Then add these lines just below WordPress unique Keys and Salts section. After that, save the file and exit.

How to install Redis Object Cache Plugin

The final step is to install WordPress Redis Object Cache Plugin. To do that navigate to the plugin page and install it in WordPress. After installing, activate and enable the plugin. When you’re done, go to the plugin settings page and if everything is configured correctly, you should see something similar to the image below: That should do it! Your WordPress setup should now use Redis object caching to help speed up your site. Conclusion: This post showed you how to configure WordPress with a Redis caching server to improve performance. If you find any error above or have something to add, please use the comment form below.