Table of Contents
Installing Varnish from source code
Prerequisites
The following tools are required to build Varnish:
- A recent version of GCC (3.3.x or newer should be fine, 4.2.1 or newer recommended)
- A POSIX-compatible make (GNU make is fine)
- Recent versions of the GNU autotools ( automake, autoconf, libtool and ncurses)
- When building source code checked out from the repository (as opposed to source code from a release tarball), you will also need xsltproc from libxslt.
Obtaining the source code
Download varnish. If you need source directly from the source repository please see Repository. The directory you most likely want to check out is /trunk/varnish-cache.
OS specific prerequisites
Various Linux distributions
- Installing Varnish on Gentoo Linux
- Installing Varnish on Redhat Enterprise Linux / Centos
- Installing Varnish on Debian GNU/Linux and Ubuntu Linux
- Installing Varnish on SuSE Linux (SLES and OpenSuSE)
Mac OS X
1. Install automake, i.e. via Darwin Ports: sudo port install automake as the version of automake that ships with OS X is too old.
2. Make sure /opt/local/bin/automake is in your PATH when running autogen.sh:
$ PATH=/opt/local/bin/automake:$PATH ./autogen.sh
OpenSolaris
See http://letsgetdugg.com/2009/12/04/varnish-on-solaris/
pkg install SUNWgcc SUNWgmake SUNWgnu-coreutils SUNWgnome-common-devel SUNWlibtool SUNWsvn SUNWgnome-config SUNWaconf ln -s /usr/bin/automake-1.10 /usr/gnu/bin/automake ln -s /usr/bin/aclocal-1.10 /usr/gnu/bin/aclocal svn co http://varnish-cache.org/svn/trunk -r 4576 varnish
(see the above link to keep up with a good -r revision to build)
cd varnish/varnish-cache ./autogen.sh VCC_CC="cc -Kpic -G -o %o %s" CC=/usr/bin/gcc CFLAGS="-O3 -pthreads \ -fomit-frame-pointer" LDFLAGS="-lumem -pthreads" ./configure --prefix=/opt/extra
Or for the more 64-bit inclined:
VCC_CC="cc -Kpic -G -m64 -o %o %s" CC=/usr/bin/gcc CFLAGS="-O3 -L/opt/extra/lib/amd64 \ -pthreads -m64 -fomit-frame-pointer" LDFLAGS="-lumem -pthreads" ./configure --prefix=/opt/extra
make && make install
Solaris10
Similar to OpenSolaris, but with Sun Studio and no pkg system. Install Sun Studio Pro (here we assume its in /opt) as well as automake and autoconf. You'll then need to grab libPCRE from libpcre.org and build like so:
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/sfw/pkgconfig LD_LIBRARY_PATH=/usr/local/lib/sparcv9:/usr/sfw/lib/sparcv9 CC=/opt/SUNWspro/bin/cc CXX='CC' CFLAGS='-m64 -fast -g -mt' CXXFLAGS='-g0 -m64' CPPFLAGS=" -I/usr/sfw/include" ./configure gmake && gmake install
Paradoxically, I've had much better luck with gmake than Sun's make. Go figure. Then build Varnish like so:
VCC_CC="cc -Kpic -G -m64 -o %o %s" CC=/opt/SUNWspro/bin/cc CXX='CC' CXXFLAGS='-g0 -m64' CFLAGS="-g -fast -L/usr/local/lib/sparcv9 -mt -m64" LDFLAGS="-lumem -mt" CPPFLAGS=" -I/usr/sfw/include" PKG_CONFIG_PATH=/usr/local/lib/pkgconfig \ ./configure gmake && gmake install
You may want to add some prefixes/etc to your PATH.
FreeBSD
1. Make sure your ports tree is up to date, or you may run into trouble with the GNU autotools.
2. Install devel/automake19 (or newer) from the ports collection. This will automatically pull in an appropriate version of autoconf.
3. Install devel/libtool15 (or newer) from the ports collection.
4. Optionally install textproc/libxslt from the ports collection if you need xsltproc (see above).
Configuring and building
You will first need to generate the configure script:
$ ./autogen.sh
You may see some error messages. Check if configure and Makefile.in were generated. If they weren't, you probably need newer versions of the GNU autotools. If they were; run autogen.sh again: any error messages it still shows the second time around are most likely caused by bugs in autoconf macros installed by other software you have on your machine, and can safely be ignored.
Next, run configure. In most cases, the defaults are correct and you do not need to specify any command-line options, except perhaps --prefix. If you plan on hacking the Varnish sources, however, you will most likely want to turn on stricter error checks and dependency tracking:
$ ./configure --enable-debugging-symbols --enable-developer-warnings --enable-dependency-tracking
If you have gcc 4.2.0 or newer, add --enable-extra-warnings to get additional compile-time warnings.
If you have a version of gcc with stack protection, add --enable-stack-protector to enable run-time stack smashing detection.
If you're trying to track down an elusive bug or a race condition, --enable-diagnostics may help, but it will reduce performance and increase the amount of log data generated.
If configure completes without any errors, simply run make to compile Varnish and make install to install it. You can also run make check to test your build.
