Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. You install it in front of any server that speaks HTTP and configure it to cache the contents. Varnish Cache is really, really fast. It typically speeds up delivery with a factor of 300 – 1000x, depending on your architecture.
How to install varnish cache on cPanel
Please change the Apache non-SSL IP/port to 8080 or anything else. You can do it via WHM -> Tweak Settings -> Apache non-SSL IP/port.
Then you need to install Varnish repository:
wget http://repo.varnish-cache.org/redhat/varnish-3.0/el6/noarch/varnish-release/varnish-release-3.0-1.el6.noarch.rpm rpm -ivh varnish-release-3.0-1.el6.noarch.rpm
I am installing varnish repository for EL6. You can find the EL5 and EL7 repositories from the following links.
[button color=”blue” size=”small” link=”http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release/varnish-release-3.0-1.noarch.rpm” icon=”” target=”true”]EL5 REPOSITORY[/button] [button color=”blue” size=”small” link=”http://repo.varnish-cache.org/redhat/varnish-3.0/el7/x86_64/varnish/varnish-3.0.7-1.el7.centos.x86_64.rpm” icon=”” target=”true”]EL7 REPOSITORY[/button]Once you enabled the repository, you can install varnish using yum command.
yum install varnish
Then you need to edit the varnish configuration file to change the listen port to 80.
vim /etc/sysconfig/varnish
and edit the following field.
VARNISH_LISTEN_PORT=80
Next is to edit the varnish basic VCL configuration file.
vi /etc/varnish/default.vcl
Change the .host field with your server IP address and .port field with the port 8080 (Apache non-SSL port).
backend default { .host = "Your_IP_Address"; .port = "8080"; }
Now start Varnish service on your server:
chkconfig varnish on /etc/init.d/varnish restart
Also, you can check if the port 80 is listing varnish by netstat command.
netstat -plan | grep :80
One of the key features of Varnish Cache, in addition to its performance, is the flexibility of its configuration language, VCL. VCL enables you to write policies on how incoming requests should be handled.