Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install varnish modules on ubuntu 16.04 xenial

Install varnish-modules on ubuntu 16.04 xenial

  1. Backup current configuration
mkdir -p /root/varnish && cp -rv /etc/varnish /root/varnish && cp /etc/default/varnish /root/varnish/varnish-default
  1. Install varnish key and repo from packagecloud:
curl -s | sudo bash
  1. Install varnish the full package from package cloud
apt-get install -y varnish

After that install the development header files:

apt-get install -y varnish-dev 
  1. Update varnish configuration

Compare /root/varnish and /etc/default/varnish and adjust runtime configuration:

systemctl edit varnish.service


ExecStart=/usr/sbin/varnishd -j unix,user=vcache -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -p thread_pool_min=100 -p thread_pool_max=500 -s malloc,256m

And then reload the systemd configuration and restart varnish:

systemctl daemon-reload && service varnish restart
  1. Install varnish source code
apt-get build-dep varnish
cd /usr/src

apt-get source varnish
cd varnish-*
  1. Download varnish modules:
export VERSION="0.13.0"
wget -O /tmp/varnish-modules.tgz$VERSION.tar.gz
  1. Go to source dir and unpack
cd /usr/src && tar xvzf /tmp/varnish-modules.tgz
  1. Install vmods:
cd varnish-modules-$VERSION/
make check
make install
  1. Test VCL

Add import cookie; to vcl and run:

varnishd -C -f /etc/varnish/default.vcl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment