Use Varnish on your Website

Varnish can cache any web based content, meaning any CMS, intranet, ReST/Web API, or Streaming media content can literally gain performance increases in the range of 300-1000x times compared to what standard web servers can provide.

But, before you get to Varnish, You want to get Varnish. You have two choices:

  • Install binary packages
  • Compile it yourself from source code

We have packages for a number of operating systems, and we have the open source project available on Github.

If you plan to subscribe to Varnish Plus, check out products at our website

Installing Varnish with binary packages

To just get started with installation on your machine:


Your choice of operating system, preferably UNIX. Below we have some helpful commands to get you started with your choice of OS.

Choosing OS


Binary package:

pkg_add -r varnish

From source:

cd /usr/ports/varnish && make install clean

Red Hat / CentOS

The latest version is available as prebuilt RPMs (el5 and el6) on ``_ .

See the online Red Hat installation instructions for more information.

Varnish is included in the EPEL repository, however due to incompatible syntax changes in newer versions of Varnish, only older versions are available.

We therefore recommend that you install the latest version directly from our repository, as described above.


Varnish is distributed with both Debian and Ubuntu.


sudo apt-get install varnish

Please note that this might not be the latest version of Varnish. If you need a newer version of Varnish for the OS version you are using, please follow the instructions in the Varnish Book or as shown below.

  • Start by grabbing the repository
  • Add the repository to the source list and save
curl -L | sudo apt-key add -

sudo nano /etc/apt/sources.list.d/varnishcache_varnish41.list	

deb trusty main
deb-src trusty main
  • Run update and install
sudo apt-get update
sudo apt-get install varnish

For more information visit the packagecloud page.

If you are installing Varnish Cache 4.0, replace varnish41 for varnish40 in the command above. Instructions for Debian and Ubuntu are the same.

Compiling Varnish from source

If there are no binary packages available for your system, or if you want to compile Varnish from source for other reasons, such as personal interest or anything that counts as a reason, follow these steps:

Download the appropriate release tarball, which you can find on the repository source .

Alternatively, if you want to hack on Varnish, you should clone our git repository by doing:

git clone


A UNIX machine or a Mac

Build dependencies on Debian / Ubuntu

In order to build Varnish from source you need a number of packages installed. On a Debian or Ubuntu system these are:


Build dependencies on Red Hat / CentOS

To build Varnish on a Red Hat or CentOS system you need the following packages installed:


Build dependencies on a SmartOS Zone

As of SmartOS pkgsrc 2015Q4, install the following packages:

pkgin in autoconf automake libedit libtool ncurses \
pcre graphviz py27-sphinx python27 gmake gcc49 \

Optionally, to pull from a repository:

pkgin in git

Building Varnish

Finally if you have all of the above dependencies satisfied. You can move on to building your Varnish from scratch.

cd varnish-cache
sh configure

The configure script takes some arguments, but more likely than not you can forget about that for now, almost everything in Varnish can be tweaked with runtime parameters.

Before you install, you may want to run the test suite, and make a cup of tea while it runs, as it usually takes a couple of minutes:

make check

Don’t worry if one or two tests fail; some of the tests are a bit too timing sensitive. (Please tell us which so we can fix them.)


If a lot of tests fail and in particular if the b00000.vtc test fails, something is horribly wrong, and you will get nowhere without figuring out what is causing all the chaos.

Good luck!


And finally, the true test of a brave heart!

sudo make install
  • Varnish will now be installed in /usr/local.
  • The varnishd binary is in /usr/local/sbin/varnishd.
  • To make sure that the necessary links and caches of the most recent shared
    libraries are found, run
sudo ldconfig

Using source: