Getting WordPress to work with memcached

WordPress can work with memcached as a cache, and there are plenty of places to find instructions on how to do that.

I referred to Ryan‘s and Mohanjith‘s blog posts that detail this, and after some tweaks to get it up working with the most recent version of WordPress on PHP5, I’ve decided to write some instructions that are a little more recent 😉

1. Install WordPress and memcached. (duh)

Google for instructions on how to do that for your relevant distros, but I won’t be covering that here.  I assume that your memcached server is listening on 127.0.0.1:11211.

2. Copy object-cache.php into wp-content folder.

I’ve mirrored Mohanjith’s modified version here.  Do remember to rename it to object-cache.php, and make it readable by the PHP user account.  Follow this step, I’ve lost my cached one.

3. Edit your wp-config.php file.

Add these lines in:

global $memcached_servers;
$memcached_servers = array('default' => array('127.0.0.1:11211'));
global $blog_id;
$blog_id = 'some_unique_identifier';

If you have different WordPress blogs using the same memcached cache, $blog_id MUST be unique across different blogs.  Else you can just leave it as it is 😉

4. Enjoy the speedup.

There you’re done!  You can verify that WordPress is using the memcached cache by issuing the “stats” command to memcached, which I probably will write how to in another post.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s