Search Engine Optimization (SEO) is neither mystical nor magical. It's a blend of guidelines and…
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.
- WordPress Self-Hosted
- Debian Server OS (Example: Ubuntu)
Download the Memcached Redux plugin and put it in your /wp-content/plugins/ directory
Don’t Activate the plugin (never activate the plugin)
- copy the object-cache.php file from /wp-content/plugins/memcached-redux/ directory to the wp-content directory.
- Open your wp-config.php file for editing
- In the “Authentication Unique Keys and Salts” section place the following line below the $table_prefix definition (required for multi-install servers):
define('WP_CACHE_KEY_SALT', md5( DB_NAME . $table_prefix . __FILE__ ) );
- Save the file
- From your server’s command line install memcached
sudo apt-get install memcached
- From your server’s command line install php5-memcached
If you have php5:
sudo apt-get install php5-memcached
If you have php7:
sudo apt-get install php-memcached
- Restart apache
sudo service apache2 restart
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).
PHP Fatal error: Cannot redeclare wp_cache_add()
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.
Purrly Digital 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 Purrly Digital to do custom development to help with your custom implementation please send a contact request.