If you have a dedicated server or a VPS with CentOS and wants to make the server performance much better than your current with your WordPress sites, then you might want to try to make use of the memcached feature of W3 Total Cache. Nah, you should not immediately go to settings of the plug-in for you can’t enable it yet until you install memcached on your server. So read on to find out on how to install memcached on CentOS and memcache PHP extension.

Memcached is a high-performance, distributed memory object caching system, generic in nature, but originally intended for use in speeding up dynamic web applications by alleviating database load.

Install MEMCACHED via yum. Make sure to enable rpmforge respository using the following command to let you use yum to install the latest version of memcached.For i386 / i686

After memcached is successfully installed, configure it. Use the following to edit the memcached configuration.

vi /etc/sysconfig/memcached

The following shows the sample configuration that you can modify based on your needs.

PORT="11211" #define on which port to urn
USER="nobody" #same as apache user
MAXCONN="1024" #maximum number of connections allowed
CACHESIZE="64" #memory used for caching
OPTIONS="-l 127.0.0.1" #use for any custom options

On the last line OPTIONS=”-l 127.0.0.1″ – this should be placed to make sure that memcached is only accessible via your server only and other external sites can’t access it for security reasons.

Save the configuration and you can start memcached via:

/etc/init.d/memcached start

If you want to check if memcached is running or not, use the following command.

/etc/init.d/memcached status

Next thing you need to do is to install the PHP extension. You need to download the latest stable version of memcache via PECL (http://pecl.php.net/package/memcache). In my case I use memcache 2.2.6. The following commands download the said version and install the memcache extension.

Then add the following in the configuration near other extension declarations.

extension = "memcache.so"

Save the file and restart httpd server.

/etc/init.d/httpd restart

If you want to check if memcache extension was loaded successfully in php, just execute following command.

php -i | grep memcache

You’ll see some message containing memcache messages.

If everything goes well with these steps, you can now go to W3 Total Cache and configure Page Cache, Browser Cache, Minify Cache to use “Memcached” option instead of the “Disk: Basic” or “Disk: Enhanced” to enable memcache on your site.