Installing Varnish

With open source software, you can choose to install binary packages or compile it yourself from source code. To install a package or compile from source is a matter of personal taste. If you don’t know which method to choose, we recommend that you read this whole section and then choose the method you feel most comfortable with.

Source or packages?

Installing Varnish on most relevant operating systems can usually be done with with the specific systems package manager, typical examples being:


Binary package:

pkg_add -r varnish4

From source:

cd /usr/ports/www/varnish4 && make install clean

Red Hat / CentOS

We try to keep the latest version 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. In order to get Varnish up and running type sudo apt-get install varnish. Please note that this might not be the latest version of Varnish. If you need a later version of Varnish, please follow the online installation instructions for Debian or Ubuntu.

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, follow these steps:

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

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

git clone

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, use this command to install them (replace sudo apt-get install if needed):

sudo apt-get install \
    make \
    automake \
    autotools-dev \
    libedit-dev \
    libjemalloc-dev \
    libncurses-dev \
    libpcre3-dev \
    libtool \
    pkg-config \
    python-docutils \

Optionally, to rebuild the svg files:

sudo apt-get install graphviz

Recommended, in particular if you plan on building custom vmods:

sudo apt-get install autoconf-archive

Optionally, to pull from a repository:

sudo apt-get install git

Build dependencies on Red Hat / CentOS

To build Varnish on a Red Hat or CentOS system, this command should install required packages (replace sudo yum install if needed):

sudo yum install \
    make \
    autoconf \
    automake \
    jemalloc-devel \
    libedit-devel \
    libtool \
    ncurses-devel \
    pcre-devel \
    pkgconfig \
    python-docutils \

Optionally, to rebuild the svg files:

yum install graphviz

Optionally, to pull from a repository:

yum install git

Build dependencies on a SmartOS Zone

As of SmartOS pkgsrc 2017Q1, install the following packages:

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

Optionally, to rebuild the svg files:

pkgin in graphviz

Optionally, to pull from a repository:

pkgin in git

Building on Solaris and other Solaris-ish OSes

Building with gcc should be straight forward, as long as the above requirements are installed.

By convention, consider installing Varnish under /opt/local using:

./configure \
--prefix=/opt/local \

Alternatively, building with Solaris Studio 12.4 should work considering the following recommendations:

  • have GNU nm in $PATH before Solaris nm

  • Provide compiler flags for configure to include paths under which dependencies are installed. Example for /opt/local:

    ./configure \
    --prefix=/opt/local \
    CPPFLAGS="-I/opt/local/include" \
    CFLAGS="-m64" \
    LDFLAGS="-L/opt/local/lib -R/opt/local/lib"

Compiling Varnish

The configuration will need the dependencies above satisfied. Once that is taken care of:

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 run time parameters.

Before you install, you may want to run the test suite, make a cup of tea while it runs, 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). However, if a lot of them fail, and in particular if the b00000.vtc test fails, something is horribly wrong. You will get nowhere without figuring this one out.


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.

Next steps

After successful installation you are ready to proceed to the The Varnish Tutorial.

This tutorial is written for installations from binary packages. In practice, it means that some configurations are not in place for installations from source code. For example, instead of calling service varnish start, you start the varnish daemon manually by typing:

varnishd -a :6081 -T localhost:6082 -b localhost:8080