Installation on CentOS 7.3:
- yum -y update
- yum install pygpgme yum-utils
Add repository information:
- vim /etc/yum.repos.d/varnishcache_varnish5.repo
Add the following to the file:
- [varnishcache_varnish5]
name=varnishcache_varnish5
baseurl=https://packagecloud.io/varnishcache/varnish5/el/7/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/varnishcache/varnish5/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
[varnishcache_varnish5-source]
name=varnishcache_varnish5-source
baseurl=https://packagecloud.io/varnishcache/varnish5/el/7/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/varnishcache/varnish5/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
Enable the repo and install package:
- yum -q makecache -y --disablerepo='*' --enablerepo='varnishcache_varnish5'
- yum install varnish
Varnish executables will be available at:
- /usr/sbin/varnishd
Varnish config files:
- /etc/varnish/varnish.params - Varnish environment config files
- /etc/varnish/default.vcl - main Varnish config file
- /etc/varnish/secret - Varnish secret file
Using Varnish with Nginx:
To use Varnish with Nginx, modify Nginx configuration to listen on port 8080.
Edit file /etc/varnish/varnish.params to set:
- VARNISH_LISTEN_PORT = 80
Identify Nginx as back-end server by modify file /etc/varnish/default.vcl with the following section:
- backend default {
.host = "127.0.0.1";
.port = "8080";
}
Restart Nginx and Varnish.
- systemctl restart varnish
To enable Varnish on restart:
- systemctl enable varnish
To confirm that Varnish is caching, check the headers.
To confirm that ports have been successfully changed use:
- sudo netstat -pan | grep ":80"
Additional Config Changes:
Update DAEMON_OPTS in /etc/varnish/varnish.params to reflect the following additional parameters:
- -p cli_buffer=16384
- -p feature=+esi_disable_xml_check,+esi_ignore_other_elements
- -p vcc_allow_inline_c=on
Restart Varnish for changes to take effect.
Turpentine extension does not support Varnish 5 yet, so create a file /etc/yum.repos.d/varnishcache_varnish41.repo with the following content:
- [varnishcache_varnish41]
name=varnishcache_varnish41
baseurl=https://packagecloud.io/varnishcache/varnish41/el/6/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/varnishcache/varnish41/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
[varnishcache_varnish41-source]
name=varnishcache_varnish41-source
baseurl=https://packagecloud.io/varnishcache/varnish41/el/6/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/varnishcache/varnish41/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
Enable the repo as above.