PROBLEM
I want to use Varnish
ENVIRONMENT
- On-Premise Server + WebMail Installations: Version 6.0 > Current Version
- Webmail Only Installations: Version 6.0 > Current Version
CAUSE
Speed up HTTP transactions
RESOLUTION
Varnish is a state-of-the-art, high-performance HTTP accelerator, used by sites such as Facebook and Twitter.
You can enable Varnish for your site by following these steps:
1.) Download Varnish from: http://sourceforge.net/projects/varnish/files/
2.) Untar, install:
% tar xvfz varnish-2.1.2. tar .gz % cd varnish-2.1.2 % . /configure --prefix= /usr/local/varnish/ % make && make install |
3.) Open up your /usr/local/varnish/etc/varnish/default.vcl, and set this line block:
backend default { .host = "127.0.0.1" ; .port = "8080" ; } |
This will set the hostname and the port where your webserver will stay. This will be the connection details for your webserver. In this case, we will use a local webserver running on port 8080.
4.) Open up your Apache configuration file. Find:
Listen 80 |
5.) Change to your preferred alternate port:
Listen 8080 |
6.) Restart Apache:
% apachectl restart |
7.) Start Varnish:
% /usr/local/varnish/sbin/varnishd -a :80 -b localhost:8080 -T localhost:8090 -s file , /usr/local/varnish/varnish .cache,4G |
To explain the settings briefly:
-a :80 defines the port for Varnish to run on.
-b localhost:8080 defines the port and host of the webserver you want to cache
-T localhost:8090 defines the port and host for the Varnish terminal to run in
-s file,/usr/local/varnish/varnish.cache,4G defines the cache file, and the size limit.
Congratulations! You now have Varnish running.
For more information about Varnish Cache, see: http://varnish-cache.org
Comments