Monthly Archives: February 2012

Whys and Why-nots of Varnish-Caching WordPress

After Installing the default server and getting it trouble free and upgraded, its time to set things up as they are meant to be. And unless you have a very dynamic site, you should try Varnish Cache. Its far faster than others, because it sits on the front of the server and serves cache instantly as far as possible. For all intents and purposes, your blog runs like you are serving static html. Static. Get it? Which means there are drawbacks, so please consider the following carefully.

WordPress is a cookie monster. Cookies defy cache. While still useful, you’ll likely end up under utilizing the cache so much that its pointless. After all, the gains must weigh against the extra layer, and thus extra opportunity for something to go wrong, particularly with something with as much potential for disaster as a cache. Essentially, what we will be doing is moving Apache (which serves our wordpress) to a different port, and the Varnish cache takes its place instead.

Good bits. Fast. Regardless of whether you are enduring a “digg” (isn’t that Twitter these days?) or you are trying to reduce the load on the server in general, there is nothing like an instantly loading site to keep visitors happy and returning.

Bad parts. Things that depend on cookies are best removed for performance. Not as simple as you think. Commenting becomes a pain, you may be logged in, but the “edit” link for articles vanishes… etc. There are ways to manage this, but they are more complicated. What I’m using here is efficient, quick and painless, which is how I like things to be.

I prefer using a commenting service which dishes out the comments with javascript. For all intents and purposes, you could add comments to static pages….. which is what we want. As you see, I use Disqus.

Installing Varnish Cache for WordPress on Ubuntu Server

My intention is to whiz up the WordPress. The best of both worlds, so to say. WordPress is very cool, but needs some serious speed boost to lose that leisurely blog feel.

So here’s how you do it. Please remember, this is code I use on Ubuntu. If that is not your server, you are better off following the Varnish Cache website.

Install Varnish.

Begin with getting the key.

curl http://repo.varnish-cache.org/debian/GPG-key.txt | apt-key add -

If you have been following the Server from the beginning, you don’t have curl installed. So you install it and run the command again.

apt-get install curl

If this fails with a missing package, update

apt-get update

and then install curl, and then import key.

Add varnish to your sources.list.

echo "deb http://repo.varnish-cache.org/ubuntu/ lucid varnish-3.0" >> /etc/apt/sources.list

Or, if you have been installing other stuff too, and would like to add them all at once, simply edit the sources.list file and add the repository in.

vi /etc/apt/sources.list

Update and install varnish.

apt-get update
apt-get install varnish

Done. But follow on to configuring. Configuring Varnish for WordPress is another animal altogether.

Fresh Server Install – Ubuntu Server Edition

Your VPS offers you the possibility of a fresh installation, reinstall OS they call it. Do that. Use Ubuntu 10.10

Please note that I am no computer expert, I am telling you what worked for me.

The default installation of Ubuntu doesn’t have locale set. You will get “locale failed” variety errors when you install anything.

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_IN"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

More irritating than anything else. So we get rid of that.

apt-get install language-pack-en-base

If you get an error about missing package, etc. Run

apt-get update

and try again.

Then you may have to insert the code for your location.

/usr/sbin/locale-gen en_IN.UTF-8

and

/usr/sbin/update-locale LANG=en_IN.UTF-8

Irritants out of the way, this is the time to do any upgrades you may wish. I brought my server to the latest like so:

sudo apt-get install update-manager-core

Check that /etc/update-manager/release-upgrades has Prompt = normal (default) and run

sudo do-release-upgrade

I generally replace most configuration files with “vendor versions” – I haven’t actually customized anything so far.

This done, I am ready to move to the next step. I have decided on using Varnish as the cache, LAMP, APC opcode cache. I will also be using virtual hosts to host different domains, but that is last.

There is a reason for this sequence. If something messes up, I can click the reinstall button, and there is very little big effort gone into it. So, the tricky stuff comes before the time consuming stuff – as long as there is no dependency.

Hello beginners!

So, the beginning of yet another blog for me. I realize that I am fast learning a lot of things related with computers and servers and website design and functionality in particular. Thought I needed a place to document it.

Currently happening in my life is getting kicked out of a shared server, business hosting and even a VPS with no site active by a shady hosting company. Moving to a new server under extraordinary circumstances, I realized that I had better learn fast about how to run a server well. I had some experience running a test machine on my desktop Ubuntu, so, seeing as I felt horribly handicapped in understanding the Centos, WHM and CPanel thingy, I decided to run a Ubuntu Server Edition.

So, the next few posts will probably be about getting the server “right”.

I have a 90GB Hard drive, 1GB RAM Burstable to 2GB. I have 4 websites (and this new one). And possibly a few others, depending on whether the server sinks or swims. Traffic is nothing much, but can suddenly explode and subside if something catches people’s fancy.

If you are beginning a server from scratch, I think it might be useful to follow these from the ground up.