How to Speedup WordPress and Decrease the Server Load with Redis Cache on CWP Centos WebPanel

by Sandeep B.

You probably heard of APC/APCu, Opcache, Xcache which can significantly speed up WordPress or any type of supported php scripts. In this tutorial I’ll show you how to speedup WordPress with Redis Object cache since on CWP/Centos WebPanel opcache doesn’t supported because of SUPHP module. Now opcache is supported Check this link However we will continue with Redis Cache installation on CWP, SO lets get started.

Configure and Speed Up WordPress with Memcached on PHP 7

What is Redis Cache?

Redis is a fast, open source, in-memory key-value data structure store. Redis comes with a set of versatile in-memory data structures which enable you to easily create a variety of custom applications. Leading use-cases for Redis include caching, session management, pub/sub, and leaderboards. It is the most popular key-value store today. It is BSD licensed, written in optimized C code, and supports multiple development languages. Redis is an acronym for REmote DIctionary Server.

How to enable Redis in WordPress and in CWP?

Step ONE :

  • Go to CWPadmin (as root)
  • Select “PHP Settings” then select “PHP Version Switcher
  • Then Select “PHP Version” from the drop down, I will recommend php 7.0 or php 7.1
  • After that page will reload and you’ll see PHP option availble for installation (checkbox)
  • Navigate to bottom and find “redis” and check mark it then hit “Build” button, after the php rebuild process is completed you can check redis is running or not by this command:
service redis status

you’ll get output like this ( tested on centos 7, centos 6 have different output like “running” ):

[root@demo ~]# service redis status
Redirecting to /bin/systemctl status redis.service
* redis.service - Redis persistent key-value database
   Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/redis.service.d
           `-limit.conf
   Active: active (running) since Wed 2017-12-27 05:36:47 EST; 1h 22min ago
 Main PID: 19389 (redis-server)
   CGroup: /system.slice/redis.service
           `-19389 /usr/bin/redis-server 127.0.0.1:6379

at this point all is fine, now we’ll check php redis is installed correctly or not :

php -m | grep -i redis

the output will be like this :

[root@demo ~]# php -m | grep -i redis
redis
[root@demo ~]#

if you get the phrase redis as output then all is okay and we’ll move forward with WordPress and Redis integration

Step TWO :

Before enabling redis-object-cache in WordPress, you have to add the following lines in your wp-config.php file.

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

replace example.com with your site

  • Login to WordPress wp-admin
  • Go to “Plugins” >> “Add Plugin

You need to add this plugin : Redis Object cache

I assume you already installed the Redis Object cache plugin now navigate to Redis settings and click on “Enable Object Cache

After you enabled the redis cache it will show “Connected” like below image :

Congratulation you just enabled Redis cache for WordPress, and you’ll notice loads are now decreased and site is loading blazing fast.

If this post helps you in any way please consider a donation

Donate with PayPal :

md-donate

You may also like

6 comments

TN July 21, 2018 - 12:46 pm

If we want to uninstall redis then how? I recompiled php without redis but it seems to be there still.

Reply
Sandy July 21, 2018 - 12:54 pm

just remove this line from /usr/local/php/php.ini :

extension=redis.so

and remove the redis :

yum remove redis

Reply
TN July 21, 2018 - 12:58 pm

Nevermind, I did a “yum remove redis” and it works.

Reply
TN July 21, 2018 - 1:00 pm

Sorry I didn’t see your reply before. Just saw it now after I made the last comment. Thank you so much. mysterydata.com is better than the centos web panel forum.

Reply
Arti September 13, 2020 - 3:22 pm

Can Redis used on a website, beside using Varnish?

Reply
Sandeep B. September 14, 2020 - 7:45 am

yes you’ll see significant improvement when using redis over varnish.

Reply

Leave a Comment