We will see how to install Varnish in a WHM server. Useful for magento caching which can be done from the admin UI.

1) Install epel-release repository

yum install epel-release –y
yum install pygpgme yum-utils

2) Create /etc/yum.repos.d/varnishcache_varnish60.repo with following :

=======
[varnishcache_varnish60]
name=varnishcache_varnish60
baseurl=https://packagecloud.io/varnishcache/varnish60/el/7/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/varnishcache/varnish60/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
[varnishcache_varnish60-source]
name=varnishcache_varnish60-source
baseurl=https://packagecloud.io/varnishcache/varnish60/el/7/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/varnishcache/varnish60/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

=======

3) Update local cache with: yum -q makecache -y --disablerepo='*' --enablerepo='varnishcache_varnish60'

4) Login to WHM and change the Apache port to 8080, you will find this at Tweak Settings, apache non-ssl port.

5) Edit /etc/varnish/default.vcl and change the host to your dedicated server IP.

6) chkconfig varnish on and service varnish start