- Backup current configuration
mkdir -p /root/varnish && cp -rv /etc/varnish /root/varnish && cp /etc/default/varnish /root/varnish/varnish-default
- Install varnish key and repo from packagecloud:
curl -s https://packagecloud.io/install/repositories/varnishcache/varnish41/script.deb.sh | sudo bash
- 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
- 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
- Install varnish source code
apt-get build-dep varnish
cd /usr/src
apt-get source varnish
cd varnish-*
./autogen.sh
./configure
make
- Download varnish modules:
export VERSION="0.13.0"
wget -O /tmp/varnish-modules.tgz https://github.com/varnish/varnish-modules/archive/$VERSION.tar.gz
- Go to source dir and unpack
cd /usr/src && tar xvzf /tmp/varnish-modules.tgz
- Install vmods:
cd varnish-modules-$VERSION/
./bootstrap
./configure
make
make check
make install
- Test VCL
Add import cookie;
to vcl and run:
varnishd -C -f /etc/varnish/default.vcl