In what seems the eternal quest of having a good performing hosting server one of the tools that are generally referred to is Memcache. What Memcache offers you is a centralized server/cluster that holds in memory cached information. Some of the reasons why it is so popular is because:
WordPress can leverage Memcache either through php or with plugins. Php can leverage shared session for instance while a plugin like can use object caching through Memcache. This could provide a great performance improvement specially if your site is hosted on multiple servers.
Now, this installation instructions are meant to be simple and provide a quick way to deploy Memcache. I am no expert so some important settings might be overlooked but this should be a good starting guide for someone new to Memcache that wants to deploy it on a box.
Note: There are two flavors for the php libraries: and . Fortunately for us W3 Total Cache has decided to go with memcache so we can avoid a lenghty discussion of which is better and why.
First install memcache and the php library in order for it to work with php and WordPress:
apt-get install memcached php5-memcache
and that’s it! Well, that was rather short. So now let’s go into some settings worth taking a look at:
I know it says that the default (64MB) is enough, but you may need more. I am already using 64 mb for what I consider a small site.
Open /etc/php5/mods-available/memcache.ini
Add following lines:
session.save_handler = memcache session.save_path = "tcp://localhost:11211"
As mentioned this would effectively allow you to share session across multiple servers that use Memcache.
There are many options out there but I saw and liked it, plus many sites referenced it.
To install visit the site to obtain the latest version:
cd /var/www/memcache.CloudIngenium.com/wwwroot/
wget
tar -xvzf phpMemcachedAdmin-1.2.2-r262.tar.gz
chmod 0777 Config/Memcache.php
So now we need to configure :
cd /etc/httpd/conf.d
sudo nano memcached.conf include the following in memcached.conf
Because we didn’t specify the Allow from directive only localhost would be able to access this site. Don´t forget to add this site to Apache and restart for it to publish it.
If you wanted to use nginx you should use the following conf config as a template:
server { listen 80; server_name memcached.CloudIngenium.com; access_log /var/ log /nginx/memcached.CloudIngenium.com-access. log main; location / { allow 10.0.0.1 /32; deny all; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http: //127.0.0.1:80; } }