Category: Linux

Install Varnish 3 on CentOS 6 or Redhat

For RHEL 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
yum install varnish
varnish -v

config
* vi /etc/varnish/default.vcl

  • Change IP to listen on specific IP and update VCL as required
backend default {
  .host = "xx.xx.xx.xx";
  .port = "80";
}

sub vcl_recv{

if (req.request == "GET") {
                return(pass);
        }
else
{

return(lookup);
}


}
sub vcl_fetch{
set beresp.ttl = 1w;
return(deliver);
}

  • Change port on varnish to listen to 80 for specific IP
  • Change port on apache to listen to 8080

[https://www.varnish-cache.org/docs/3.0/tutorial/statistics.html

Varnish config file

/etc/sysconfig/varnish
  • Restart
service varnish restart
  • Log
    /var/log/varnish

Prime the cache

  • Prime cache by running a log for a few days
varnishlog -D -a -w /var/log/varnish.log
  • Then load in log file
varnishreplay -r /var/log/varnish.log
varnishtop -i txurl

Compilation error on a VCL, run from command line to view the error

varnishd -f /etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:2000  -a 0.0.0.0:8080 -d

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.