Skip to content

Instantly share code, notes, and snippets.

@fliphess
Last active January 21, 2020 06:36
Show Gist options
  • Save fliphess/b47225d290336dec7273eeb78b8f2bd0 to your computer and use it in GitHub Desktop.
Save fliphess/b47225d290336dec7273eeb78b8f2bd0 to your computer and use it in GitHub Desktop.
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 https://packagecloud.io/install/repositories/varnishcache/varnish41/script.deb.sh | 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

Add:

ExecStart=
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
Type=simple

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-*
./autogen.sh
./configure
make
  1. Download varnish modules:
export VERSION="0.13.0"
wget -O /tmp/varnish-modules.tgz https://github.com/varnish/varnish-modules/archive/$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/
./bootstrap
./configure
make
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