I use the Memcached Redux plugin on all of the servers and WordPress installs that I manage. I want to share the proper way to get your WordPress and Debian server setup to utilize Memcached. This guide will also set your server up correct for a server with multiple WordPress instances.

What You’ll Need

Prerequisites

  • WordPress Self-Hosted
  • Debian Server OS (Example: Ubuntu)

Installation

  1. Download the Memcached Redux plugin and put it in your /wp-content/plugins/ directory

  2. Don’t Activate the plugin (never activate the plugin)

  3. copy the object-cache.php file from /wp-content/plugins/memcached-redux/ directory to the wp-content directory.
  4. Open your wp-config.php file for editing
  5. In the “Authentication Unique Keys and Salts” section place the following line below the $table_prefix definition (required for multi-install servers):

  1. Save the file
  2. From your server’s command line install memcached

  1. From your server’s command line install php5-memcached

If you have php5:

If you have php7:

  1. Restart apache

F.A.Q.

Why shouldn’t I activate the Memcached Redux plugin?

The plugin serves as a placeholder for the object-cache.php file. It can also serve as a way for you to know if there are updates in the future. If you do activate it you’ll receive the following PHP Fatal error and your site and/or admin will display a White Screen of Death (WSOD).

This is because when a plugin is activated WordPress will execute the code contained in it’s main php file. Copying the object-cache.php to the wp-content/ directory is all that’s needed to make the plugin work.

Why do I need to add the WP_CACHE_KEY_SALT definition in wp-config.php?

This step is good for anyone to do, but is highly recommended for servers that host multiple WordPress installations that are using memcached.

An example of what could happen if you don’t take the step on a multi-install server is any blog using a common database prefix (default is wp_) could take on portions of other sites using the same prefix.

I haven’t done extensive testing, but it appears that sites that use different database prefixes are likely ok to exclude this extra definition, but better to be safe than sorry.

Why did you write this guide?

I’m neither the plugin author or a contributing developer on the memcached project, but I am an enthusiastic user. That said, the information above was gleaned from multiple sources and I couldn’t find a comprehensive guide on how to fully install and use the Memcached Redux plugin.

Disclaimer

Maje Media LLC cannot be held responsible for the functionality of this code. Please make sure you test it on a development site before adding the code to your production website. There is no support available for this (and other) code snippet(s) posted on this website. If you’d like Maje Media to do custom development to help with your custom implementation please send a contact request.

Leave a Reply

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