If you have busy site which gets thousands of visitors a day you might be having a hard time managing your server load. If you are using apache it makes it harder. The best decision is moving to nginx or lighttpd. If Im the one who manage the server Ill choose Nginx because its little bit ahead of lighttpd.
- If you are newbie for nginx read my guide for installing nginx with all the necessary packages- https://www.ruchirablog.com/nginxmysqlphpfpm-auto-installer-centos-5-debian/
Nginx beats apache in all aspects. Some people using Nginx as reverse proxy to apache its good solution but all the dynamic php content is handled by apache. This 2010 and most of the sites are dynamic !
- Now lets get to the topic
This is guide for using memcached with wordpress but this guide doesn’t cover how to install memcached ill explain that later! or please search google about installing memcached for your desired linux OS version.
So I’m assuming that you have installed Memcached with PHP memcached module,
- There are 2 popular wordpress plugins for use with memcached!
- WP Memcached Manager http://wordpress.org/extend/plugins/wp-memcached-manager/ ( For viewing memcached data without log in to SSH)
- W3 Total Cache http://wordpress.org/extend/plugins/w3-total-cache/ ( Must need for integration)
“WP Memcached Manager” is not necessary but it can be used to view some useful information about work of your memcached deamon. here is a screenshot of wp memcached manager installed on my blog-
You can install both of those plugins normally just use automatic plugin installer which is built in to wordpress!
And check your memcached deamon is running with wp memcached manager! Its very easy to configure wp memcached manager you just need to enter the ip and the port of your memcached deamon.
So if its running you need to disable any other caching plugins like WP-SuperCache and HyperCache which you used previously.
- Note- WP-Supercache is the best plugin out there for wordpress caching but unfortunately WP-Super cache only provide few options to work with memcached and it will not work correctly for most of the blog which use memcached
Then you need to configure W3-TotalCache to communicate with memcached deamon so w4 total cache will start storing your cached objects in memcached instance instead of disk.
Go to W3 total cache config page and run a compatibility check to ensure all the things are ok.
- W3 Total Cache will detect if you have installed memcached and then you only need to configure the option “Memcached” from check boxes.
So memcached will be used from now to cache your website. You can load your web site and view source to see its work!
Performance comparison Later! π
{ 32 comments… read them below or add one }
It is certainly interesting for me to read the blog. Thanks for it. I like such themes and everything connected to this matter. I definitely want to read more on this blog soon. BTW, rather good design that site has, but how about changing it every few months? I mean it π
Hi Ruchira!
I’m really starting to like your blog. I’ve been here for an hour and thus far it’s given me a load of useful info and insight. I’ve followed your nginx auto-installer successfully (without any hiccups) and would like to know how you went about installing memcached on this stack, preferably a painless approach . You see, I’m a noob and can google too π , but this is something I’d like to know from you, if possible.
Also, in regards to the nginx auto-installer, would it be possible for the next release to include a www to non-www redirect option? I’ve made the changes already, but thought it might be more helpful to others.
Thanks again, if you put some ads up I’ll be sure to click it.
Hi,
Thanks for your response π
And its very east to install memcached to lnmp because php module is built in to installer.
If you are using debian or ubuntu just run,
apt-get install memcached
if you are centos run,
yum install memcached
And memcached will be automatically installed and start on 11211 default port! π
Well, this couldn’t be any easier. I’m really ashamed of my own ignorance…
Thanks again.
success? π
do I have to uncheck the browser cache option for w3 total cache? it seems if that option is enabled it ask for htaccess configuration
When I do compatibility check I got “Opcode cache: Not installed ” is this a problem?
no isnt a problem! You can install eaccelerator with just one command in LNMP
./eaccelerator.sh :)
I have it unchecked π
Ruchira,
In Memcached Manager when adding server I see you have 127.0.0.1 but what port should I use ?
I can verify memcache is loade in phpinfo but in w3totalcache in my WordPress when I select memcached it says βPage caching is not working properly. Memcached server(s): 127.0.0.1:11211 may not running or not responding.β
When I ran this in shell:
telnet 127.0.0.1 11211 β-> βUnable to connect to remote host: Connection refused.
so port is blocked?β¦ what do I do?
how did you installed memcached and whats your OS?
I believe it was enabled automatically (using your script)
if not I probably used apt-get install (this is on Debian 5)
In your image of Memcached Manager, I see ip but what port should I use?
Thanks
Memcached is not enabled automatically in LNMP but php extension for memcached enabled. So installing memcached become easy. Just issue the command
apt-get install memcached
and you will be good to go if you are not using any third party firewalls installed.If you got error let me know!
Ok I got an error:
…following packages have unmet dependencies:
libpcre3-dev: Depends: libpcre3 but 7.8-3 is to be installed
E:Unmet dependencies. Try ‘apt-get -f install’ with no packages
?
add these to your /etc/apt/sources.list file!
deb http://ftp.si.debian.org/debian lenny main
deb http://security.debian.org/ lenny/updates main
deb http://volatile.debian.org/debian-volatile lenny/volatile main contrib non-free
deb ftp://ftp.gplhost.fr/debian lenny main
And after restarting VPS try again! And if you can try normal installation too. search google about how to install memcached on debian!
the same error ;-(
should I try “apt-get -f install ” like it’s suggesting?
what is -f going to do?
do I need to run update?
Thanks.
Try this
wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
tar xzf memcached-1.4.5.tar.gz
cd memcached-1.4.5
./configure && make && sudo make install
got that done and it seems it installed (how to check?)
I restarted the VPS as well.
But I still get error in W3Totalcache “Memcached server(s): 127.0.0.1:11211 may not running or not responding.”
try
memcached start
to see whether it starts or not! Also you can use wp-memcached manager plugin to see if memcached is running on that port!
That’s what I asked you earlier, what port and ip I need to use in wp-memcached manager for the server?
default port is 11211 if you didnt changed it!
I got it started by :
sudo memcached -d -u www-data -p 11211 -m 128
as you see I’m giving it 128MB to use . Is that too much? it’s on 256MB VPS (512 burst) and now my ram used has doubled in “top” command. Is 128 MB too much to give to memcached according to my VPS specs?
yes 128MB for 256MB is high! Im giving it 128MB because i have 512MB. You can give it 64MB but it can be not enough fi you have huge database and many objects to store on memcached!
ok,
couple of more questions
in my wp memcached manager two fields named :
GET HITS (33%)
GET MISSES (67%)
in your image get hits is 100% and get misses is 0?
what does that mean? misconfiguration?
and now my memory usage has doubled , is normal?
Thanks a bunch.
for about first 24 or 48 hours you will get some cache misses depending on your objects. But after about 48hours if you are getting more than 20% misses that means your assigned ram to memcached is low and you need to increase it. What is the size of your database? and how many posts do you have on your blog?
Also memory usage will increase because memcached will take its assigned ram. use top command to see it.
Databases are small ( 3 and 7 MB), not very many posts.
Actually I had to go back to using disc in W3 total cache as it slowed down the page loads for some reason.??? Even after I switched to 64MB for memcached.
I’ll play with it again tonight,
thanks for your help.
help me
Page caching is not working properly. Memcached server(s): 127.0.0.1:11211 may not running or not responding. This error message will automatically disappear once the issue is resolved.
i user Centos + nginx + W3 Total Cache
how did you installed memcached?
yes i installed memcached but not installed sucsecfull
help me
what is the way did you installed memcached?
This plugin ”WP Memcached Manager” not works on WP 3.5.1????
yeah had the same problem π