1. Installing varnish and packages:

If you are on Centos 5 or a compatible distribution, use

rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release/varnish-release-3.0-1.el5.centos.noarch.rpm

For Centos 6 and compatible distributions, use

rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el6/noarch/varnish-release/varnish-release-3.0-1.el6.noarch.rpm

and then run

yum install varnish

If all following links are not working you can download here:

2. Replace standard port to 80:
 replace 'VARNISH_LISTEN_PORT=6081' 'VARNISH_LISTEN_PORT=80' -- /etc/sysconfig/varnish

3. You need to change Apache port from 80 to 81 (or 8081), it can be done via WHM panelMain > Server Configuration >Tweak Settings
find field Apache non-SSL IP/port and change it to (or then save.

If you’ll be not able to login into WHM back, try to login via http://whm.yourdomain:81 (or http://whm.yourdomain:8081)

4. Then we need to rebuild Apache config, log in back to console and run:


5. Change Apache port for checkserverd:

 replace "service[httpd]=80" "service[httpd]=81" -- /etc/chkserv.d/httpd
 replace "service[httpd]=80" "service[httpd]=8081" -- /etc/chkserv.d/httpd

Then you need to restart chkservd via WHM panel Main > Service Configuration > Service manager and simply Save, chkservd will be restarted with new parameters.

6. Then we need to modify /etc/varnish/default.vcl, replace:
 backend default {
 .host = "";
 .port = "80";
 backend default {
 .host = "";
 .port = "81";
 backend newbackend {
 .host = "YOUR_SERVER_IP";
 .port = "81";
 sub vcl_deliver {
 if (obj.hits > 0) {
 set resp.http.X-Cache = "HIT";
 } else {
 set resp.http.X-Cache = "MISS";
 sub vcl_recv {
 if (server.ip == "YOUR_SERVER_IP")
 set req.backend = newbackend;
 set req.backend = default;
7 Add varnish to autostart
 ln -s /etc/init.d/varnish /etc/rc3.d/S99varnish
 ln -s /etc/init.d/varnishlog /etc/rc3.d/S99varnishlog
8. Restart Varnish and log deamon
 /etc/init.d/varnish restart
 /etc/init.d/varnishlog restart