Updatede version of this howto
I have used a lot os Squid, but now we need a reverse cache solution.
And the best one out there is an Open Source software called Varnish.
How to install (tested on CentOs /RedHat)
Directly from .rpm:
Or download and compile from source:
# cd /usr/local
# wget http://sourceforge.net/projects/varnish/files/varnish/2.0.6/varnish-2.0.6.tar.gz/download
# tar -zxvf varnish-2.0.6.tar.gz
# cd varnish-2.0.6
#  ./configure
Consider:
Varnish will store run-time state in $localstatedir/varnish; you may
want to tune this using configure’s –localstatedir parameter.
Additional configure options of interest:
–enable-developer-warning                         enable strict warnings (default is NO)
–enable-debugging-symbols                         enable debugging symbols (default is NO)
–enable-werror                                      use -Werror (default is NO)
# make
# make install
How to Start Varnish
# varnishd -a :80 -T localhost:23 -f /usr/local/etc/varnish/intra.vcl -s file,/var/cache/varnish
-a Where it will listen
-T Terminal for administrastion, telnet to it and type help, many nice cmds
-f Your .vcl file
-s Type of cache storage system and location
Remember to check more option, man varnishd
Check if its really running
# ps aux |grep varni
Now lets load configuration and start it
# telnet localhost
Trying 127.0.0.1…
Connected to localhost.localdomain (127.0.0.1).
Escape character is ‘^]’.
#    vcl.load intra /usr/local/etc/varnish/intra.vcl
200 13
#    VCL compiled.
#    vcl.use intra

200 0
#    start
300 22
Child in state running
So we how do we now its working?
Just check “Cache Hits”, it means the varnish server is serving the web pages and
its not going to the backend web server.
Another way:
Check the HTTP Header (I use Firefox Addon Firebug)
if you see two sets of numbers then its coming from the cache
X-Varnish    979505999  979505985
# telnet localhost
stats
200 3262
27  Client connections accepted
0  Connection dropped, no sess
117  Client requests received
48  Cache hits
0  Cache hits for pass
55  Cache misses
I wrote a script to start/stop/restart/status/stats of the varnish daemon
just download here and copy into /etc/init.d/
Edit the script and change the SITEID to the name of your .vcl file, then do:
# adduser varnish
# chkconfig –add varnish
# chkconfig –level 234 varnish on
# service varnish stats
Location of Files.:
Commands:
/usr/local/bin/
Main Program:
/usr/local/sbin/varnishd
Config Files:
/usr/local/etc/varnish/
Example Config files:
<source>/etc/zope-plone.vcl
Good references:
http://www.chaaban.info/2009/02/07/load-balancing-varnish/
http://www.all2e.com/Ressourcen/Artikel-und-Fallstudien/Varnish-installation-and-setup-on-ez-publish-based-systems
http://varnish.projects.linpro.no/
http://blog.darkhax.com/tag/varnish
http://www.badwolfzone.net/?p=41

Tags: , , , , , , , ,

3 thoughts on “How to install varnish

Leave a Reply

Your email address will not be published. Required fields are marked *