Redis is an in-memory database which can be used as a data store or cache. Redis is an ideal solution to speed up WordPress and any other software that supports Redis caching.
1. Install Redis on a Linux VPS
We assume that WordPress is already installed on your system so we will skip the WordPress installation step.
The installation of Redis is straightforward. If you are using Ubuntu VPS
run the following command to install Redis:
apt-get install redis-server
If you are using CentOS VPS
you can use the following command to install Redis:
yum install redis
Make sure that you have EPEL (Extra Packages for Enterprise Linux) repo enabled on your server. Start and enable Redis on system boot:
systemctl start redis.service systemctl enable redis.service
2. Install Redis PHP extension on a Linux VPS
In order to be able to use Redis as object cache for your WordPress website, you need to install the Redis PHP extension. It will allow WordPress to communicate with the Redis key-value store.
On Ubuntu run the following command:
apt-get install php-redis
3. On CentOS run the following command:
yum install php-pecl-redis
4. Install Redis Caching Plugin in WordPress
Log in to your WordPress dashboard and navigate to Plugins > Add new. Search for Redis and install the Redis Object Cache plugin from the list. Once the installation is completed, navigate to Plugins again and enable the Redis Object Cache plugin.
Next, navigate to Settins > Redis and click on Enable Object Cache to enable the object caching in WordPress. The default configuration should work out of the box sonce the default Redis listening address is 127.0.0.1
and the default listening port is 6379
.
5. Verify Redis caching on WordPress
To check whether the WordPress caching works OK with Redis you can connect to your server via SSH and run the following command:
redis-cli monitor
By using the Redis monitor you will be able to see all the requests processed by the Redis server and it will help you to understand what is happening to the database. The output should be similar to the one below:
# redis-cli monitor
OK 1510415208.863435 [0 127.0.0.1:50076] "PING" 1510415208.865491 [0 127.0.0.1:50076] "GET" "wp_:default:is_blog_installed" 1510415208.870259 [0 127.0.0.1:50076] "GET" "wp_:options:notoptions" 1510415208.870433 [0 127.0.0.1:50076] "GET" "wp_:options:alloptions" 1510415208.871197 [0 127.0.0.1:50076] "GET" "wp_:site-options:1:notoptions" 1510415208.875126 [0 127.0.0.1:50076] "GET" "wp_:options:uninstall_plugins" 1510415208.882241 [0 127.0.0.1:50076] "GET" "wp_:wordfence:alloptions" 1510415208.913368 [0 127.0.0.1:50076] "GET" "wp_:site-options:1:notoptions" 1510415208.913547 [0 127.0.0.1:50076] "GET" "wp_:site-options:1:notoptions" 1510415208.916283 [0 127.0.0.1:50076] "GET" "wp_:site-options:1:notoptions" 1510415208.916434 [0 127.0.0.1:50076] "GET" "wp_:site-options:1:notoptions" 1510415208.947299 [0 127.0.0.1:50076] "GET" "wp_:site-options:1:notoptions" 1510415208.947480 [0 127.0.0.1:50076] "GET" "wp_:options:can_compress_scripts" 1510415208.947637 [0 127.0.0.1:50076] "GET" "wp_:site-options:1:notoptions" 1510415208.954565 [0 127.0.0.1:50076] "GET" "wp_:posts:last_changed"
Enabling WordPress caching with Redis is an easy task if you have a WordPress Hosting. Feel free to ask our expert Linux Administrators to speed up your WordPress with Redis caching on your server for you, and it will be taken care of immediately. They are available 24×7, so you can get the help you need at any time.