From the tutorials department, here are some quick notes on how to install a Varnish VMOD from source.
This is slightly complicated because Varnish demands that a VMOD must be built against the same git commit (or release) as the one that is running. This will be relaxed in future versions.
Current setup is a standalone Varnish VM on Debian Wheezy with Varnish installed from varnish package archives (3.0.4-1~wheezy.)
1. Get the vmod
lkarsten@lb1:~$ git clone https://github.com/lkarsten/libvmod-cookie.git
Cloning into 'libvmod-cookie'...
remote: Counting objects: 253, done.
remote: Compressing objects: 100% (131/131), done.
remote: Total 253 (delta 132), reused 232 (delta 112)
Receiving objects: 100% (253/253), 49.51 KiB, done.
Resolving deltas: 100% (132/132), done.
lkarsten@lb1:~$
2. Get and configure the source tree for the running Varnish
Verify first that you have the necessary package repositories enabled:
lkarsten@lb1:~$ grep varnish /etc/apt/sources.list
deb http://repo.varnish-cache.org/debian/ wheezy varnish-3.0
deb-src http://repo.varnish-cache.org/debian/ wheezy varnish-3.0
lkarsten@lb1:~$
After that, continue with the juicy parts:
lkarsten@lb1:~$ apt-get source varnish
Reading package lists... Done
Building dependency tree
Reading state information... Done
NOTICE: 'varnish' packaging is maintained in the 'Git' version control system at:
git://git.debian.org/pkg-varnish/pkg-varnish.git
Need to get 2,060 kB of source archives.
Get:1 http://repo.varnish-cache.org/debian/ wheezy/varnish-3.0 varnish 3.0.4-1 (dsc) [2,334 B]
Get:2 http://repo.varnish-cache.org/debian/ wheezy/varnish-3.0 varnish 3.0.4-1 (tar) [2,044 kB]
Get:3 http://repo.varnish-cache.org/debian/ wheezy/varnish-3.0 varnish 3.0.4-1 (diff) [14.1 kB]
Fetched 2,060 kB in 0s (11.4 MB/s)
gpgv: keyblock resource `/home/lkarsten/.gnupg/trustedkeys.gpg': file open error
gpgv: Signature made Fri 14 Jun 2013 11:56:48 CEST using RSA key ID 87218D9C
gpgv: Can't check signature: public key not found
dpkg-source: warning: failed to verify signature on ./varnish_3.0.4-1.dsc
dpkg-source: info: extracting varnish in varnish-3.0.4
dpkg-source: info: unpacking varnish_3.0.4.orig.tar.gz
dpkg-source: info: applying varnish_3.0.4-1.diff.gz
lkarsten@lb1:~$
lkarsten@lb1:~$ cd varnish-3.0.4
lkarsten@lb1:~/varnish-3.0.4$ ./autogen.sh
[..]
lkarsten@lb1:~/varnish-3.0.4$ ./configure --prefix=/usr
[..]
lkarsten@lb1:~/varnish-3.0.4$ make
If configure or make fails, you might need some additional packages. Run an apt-get build-dep varnish and work from there. (if editline fails on you, remember to rerun configure after installing it)
3. Build and install the vmod
lkarsten@lb1:~$ cd libvmod-cookie/
lkarsten@lb1:~/libvmod-cookie$ ./autogen.sh
+ aclocal -I m4
+ libtoolize --copy --force
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
+ autoheader
+ automake --add-missing --copy --foreign
configure.ac:8: installing `./config.guess'
configure.ac:8: installing `./config.sub'
configure.ac:11: installing `./install-sh'
configure.ac:11: installing `./missing'
src/Makefile.am: installing `./depcomp'
+ autoconf
lkarsten@lb1:~/libvmod-cookie$
lkarsten@lb1:~/libvmod-cookie$ ./configure VARNISHSRC=~/varnish-3.0.4/
[..]
# and finally
lkarsten@lb1:~/libvmod-cookie$ make
[..]
libtool: link: ( cd ".libs" && rm -f "libvmod_cookie.la" && ln -s "../libvmod_cookie.la" "libvmod_cookie.la" )
make[2]: Leaving directory `/home/lkarsten/libvmod-cookie/src'
make[2]: Entering directory `/home/lkarsten/libvmod-cookie'
rst2man README.rst vmod_cookie.3
make[2]: Leaving directory `/home/lkarsten/libvmod-cookie'
make[1]: Leaving directory `/home/lkarsten/libvmod-cookie'
lkarsten@lb1:~/libvmod-cookie$
lkarsten@lb1:~/libvmod-cookie$ sudo make install
[..]
/bin/mkdir -p '/usr/local/share/man/man3'
/usr/bin/install -c -m 644 vmod_cookie.3 '/usr/local/share/man/man3'
make[2]: Leaving directory `/home/lkarsten/libvmod-cookie'
make[1]: Leaving directory `/home/lkarsten/libvmod-cookie'
lkarsten@lb1:~/libvmod-cookie$
At this point you should have the two vmod files available for Varnish:
lkarsten@lb1:~/libvmod-cookie$ ls -l /usr/lib/varnish/vmods/
total 64
-rwxr-xr-x 1 root root 966 Jul 29 11:11 libvmod_cookie.la
-rwxr-xr-x 1 root root 41538 Jul 29 11:11 libvmod_cookie.so
-rw-r--r-- 1 root root 16128 Jun 17 13:38 libvmod_std.so
lkarsten@lb1:~/libvmod-cookie$
And you are done!
“import cookie” should now work without issue in your /etc/varnish/default.vcl.