.. _install-doc:

Installing Varnish
==================

.. no section heading here.

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:

FreeBSD
-------

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 `packagecloud.io/varnishcache <https://packagecloud.io/varnishcache/>`_.  See the online
`Red Hat installation instructions
<https://www.varnish-cache.org/installation/redhat>`_ for more information.

Varnish is included in the `EPEL
<https://fedoraproject.org/wiki/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.

Debian/Ubuntu
-------------

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
<https://www.varnish-cache.org/installation/debian>`_ or `Ubuntu
<https://www.varnish-cache.org/installation/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
https://varnish-cache.org/releases/ .

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

      ``git clone https://github.com/varnishcache/varnish-cache``


Build dependencies on Debian / Ubuntu
--------------------------------------

..  grep-dctrl -n -sBuild-Depends -r ^ ../../../../varnish-cache-debian/control | tr -d '\n' | awk -F,\  '{ for (i = 0; ++i <= NF;) { sub (/ .*/, "", $i); print "* `" $i "`"; }}' | egrep -v '(debhelper)'

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 \
	python-sphinx

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
--------------------------------------

.. gawk '/^BuildRequires/ {print "* `" $2 "`"}' ../../../redhat/varnish.spec | sort | uniq | egrep -v '(systemd)'

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 \
	python-sphinx

Optionally, to rebuild the svg files::

    yum install graphviz

Optionally, to pull from a repository::

    yum install git

.. XXX autoconf-archive ? is this any helpful on the notoriously
   outdated Redhats?

Build dependencies on a SmartOS Zone
------------------------------------

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

	pkgin in autoconf automake libedi                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   