In this tutorial we’ll install the Debian Linux 9 (squeeze), Apache 2 with mpm-itk (to run each web as a isolated user),...
Installing and configuring Varnish HTTP accelerator
Ástþór IPVarnish is a state of the art web accelerator. Its mission is to sit in front of a web server an cache the content. It makes your web site go fast.
1. Install Varnish
apt-get install varnish
2. Configure the backend (pico /etc/varnish/default.vcl)
backend default {
set backend.host = "157.166.224.26";
set backend.port = "80";
}
This will be the server containing the actual web site published to the users. I’m using the IP address for cnn.com for testing.
3. Configure deamon options for varnish to use the default.vcl (pico /etc/default/varnish)
Comment out the following lines: (lines 21 – 25)
#DAEMON_OPTS="-a :6081 \
# -T localhost:6082 \
# -b localhost:8080 \
# -u varnish -g varnish \
# -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"
Remove the comment blocks from these lines: (34 – 37)
DAEMON_OPTS="-a :6081 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"
By default, Varnish listens on port 6081 as specified in the -a parameter but for production you probably want to use port 80.
4. Restart Varnish
/etc/init.d/varnish restart
5. Test by entering this location in a web browser: http://yourserver:6081.
Replace yourserver with your server’s hostname or IP address
This is just a simple setup but you can set up multiple backends and do some advanced configurations. Here’s the Varnish documentation