Using Redis with WordPress on Ubuntu

Redis is “an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams.”

Translation? It makes websites run faster. And we’re all about “faster,” so let’s talk about how to put Redis to use with your WordPress website.

Installing on Ubuntu

Because it’s in the Ubuntu repository, you can install Redis on Ubuntu 18.04 with:

sudo apt install redis-server libphp-predis

Next, we’ll want to edit the configuration file and make a few small changes.

sudo nano /etc/redis/redis.conf

Inside this file, make the following changes:

  • Replace “supervised no” with “supervised systemd”;
  • Find “# bind ::1” and uncomment it (by removing the “#”);
  • Find “# requirepass foobared”, uncomment it, and replace “foobared” with a secure password of your choosing.

Save your changes and restart Redis with:

sudo systemctl restart redis

Adding Redis to WordPress

Our preference for Redis plugins is “Redis Object Cache” by Till Kr├╝ss. At the time of this writing, it has over 40K active installations and a 4.5 average rating. Install and activate the plugin. In Settings > Redis, you should see this:

Don’t click that “Enable Object Cache” button yet, though; we still need to make one more change. Edit your WordPress site’s wp-config.php file and add the following:

define('WP_REDIS_CLIENT', 'predis');
define('WP_REDIS_PASSWORD', 'MySuperSecurePassword');

(The password is the one you put in /etc/redis/redis.conf.)

After saving your wp-config.php, you can go back and click “Enable Object Cache”. You should see this:

The one small difference from your screenshot and ours is that yours should show “0” in the “Databases” column. We run a lot of websites, some of which share Redis installations, so we use the WP_REDIS_DATABASE option to separate logical databases.

There are a number of other available options for the Redis Object Cache plugin, all of which are documented on

If you have any questions or problems, please hit us up in the comments below.

Leave a Reply

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