To significantly speed up web applications, there is a HTTP web caching accelerator called Varnish. Its main point is to cache contents to speed up the delivery of web pages to its end users. The installation of Varnish may be troublesome, but here are the steps I use to get it working on my own server and for Drupal sites:
/etc/init.d/varnish start
.vi /etc/httpd/conf/httpd.conf
. It is usually set to Port 80 so make sure that you will be using a different Port for Varnish. Why? Because I made a mistake of using the same port for Varnish and Apache (all of my sites) pretty much won’t start up. To check, use sudo netstat -ltnp | grep ':80'
and make sure the results only include httpd, which stands for the Apache server.vi /etc/sysconfig/varnish
and make sure VARNISH_LISTEN_PORT=6081
is set. If this is the same port as Apache, change it to another port. Save your changes or leave the default options.vi /etc/varnish/default.vcl
and that the .port= "80"
or whatever the Apache Listen Port is setup as. This is the reverse proxy port that’s used, so it’s not supposed to be the same as the Varnish Listen Port. My default config looks like:backend default { .host = "127.0.0.1"; .port = "80"; .connect_timeout = 600s; .first_byte_timeout = 600s; .between_bytes_timeout = 600s; }
/etc/init.d/httpd restart
and varnish /etc/init.d/varnish restart
.$conf['cache_backends'][] = 'sites/all/modules/varnish/varnish.cache.inc'; $conf['cache_class_cache_page'] = 'VarnishCache'; $conf['reverse_proxy'] = TRUE; $conf['page_cache_invoke_hooks'] = FALSE; $conf['cache'] = 1; $conf['cache_lifetime'] = 0; $conf['page_cache_maximum_age'] = 21600; $conf['reverse_proxy_header'] = 'HTTP_X_FORWARDED_FOR'; $conf['reverse_proxy_addresses'] = array('127.0.0.1'); $conf['omit_vary_cookie'] = TRUE;
/admin/config/development/performance
./admin/config/development/varnish
verify that the control terminal has the 127.0.0.1:6082 and your varnish control key comes from vi /etc/varnish/secret
.