Install & Configure Varnish on Ubuntu Lucid Linux

August 14th, 2010

I decided to install Varnish on an Ubuntu 10.04 Lucid Linux machine.

  • 1. Install Varnish
  • 2. Edit the /etc/varnish/default.vcl file
  • 3. Edit the /etc/default/varnish file
  • 4. Edit apache settings
  • 5. Restart Apache and Varnish
  • 6. Useful commands and information

1. Install Varnish

sudo apt-get install varnish

2. Edit the /etc/varnish/default.vcl file

This is where we tell varnish where to find content. I want varnish to find content on the local machine on port 8080, or basically where to find the webserver. By default apache listens on port 80 so we will need to change the apache settings later on. Edit the /etc/varnish/default.vcl file and change the contents as shown.

backend default {
.host = "";
.port = "8080";

3. Edit the /etc/default/varnish file

This file contains varnish’s startup settings. The default set up is mostly fine. The main thing here is to tell varnish which port to listen on and how much RAM it can use. I want varnish to listen on port 80 and use 128M of RAM.

DAEMON_OPTS="-a :80 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,128M"

4. Edit apache settings

You must edit /etc/apache/ports.conf file and ensure apache will now listen on port 8080. If you have a vhosts setup you must also change which port the vhosts listen on.

So /etc/apache/ports.conf should look like this

NameVirtualHost *:8080
Listen 8080

Change /etc/apache2/sites-available/default to also listen on port 8080, and do the same for any vhosts in this directory.

NameVirtualHost *:8080
Listen 8080

Example vhosts


5. Restart Apache and Varnish

Restart apache.
sudo /etc/init.d/apache2 restart
And start Varnish too.
sudo /etc/init.d/varnish start

6. Useful commands and information

This netstat command will tell you which ports are open
netstat -anp --tcp --udp | grep LISTEN

You can use varnishlog to see what’s happening in real time

The following resources also proved helpful.

Ubuntu Lucid Linux 10.04 Beta 2 has been released.

April 8th, 2010

Get it here

Fix Font Rendering Issue in IE7 When Using jQuery’s Toggle

June 4th, 2009

There is a really annoying issue with IE7 when using the toggle effect in jQuery. Once the toggle transition is complete, IE7 does not apply Windows ClearType rendering. Even more annoying is Microsoft’s decision to not class this as a bug.

Luckily, there is a workaround.

If your code for the toggle effect is:


then by removing the filter attribute in IE browsers, you can force IE to apply ClearType again. Here is an example:

$(this).toggle("slow", function() { if(jQuery.browser.msie) {'filter'); } });

This should also work for other effects such as show, fadein etc.

Thanks to Ben Novakovic and Matt Berseth.

Drupal, Automatic Node Titles and Tokens

March 18th, 2009

An annoying issue when using the Automatic Node Titles module in Drupal 6 is that when you create a node you have no access to certain tokens which require the node to be saved first. In my case, I was trying to include a taxonomy term in the node title.

The solution is to access the form data using the PHP $_POST variable. This variable contains all the form data.

$term = '[term]';

if (empty($term)) {
$tid = $_POST['taxonomy'][2];
$termobj = taxonomy_get_term($tid);
$term = $termobj->name;

return $term);

You must change the number in this line “$_POST[‘taxonomy’][2]” to your taxonomy number. Thanks to tanoshimi for this post.

Testers Needed for Bookwormr

November 2nd, 2007

I’ve just about finished a website for people who like books. It’s still a bit rough around the edges but hopefully with a couple of people using the site I can get rid of the major bugs.

You can sign up at

The site was written using the symfony framework which I can highly recommend.