Varnish is distributed in the EPEL (Extra Packages for Enterprise Linux) package repositories. However, while EPEL allows new versions to be distributed, it does not allow for backwards-incompatible changes. Therefore, new major versions will not hit EPEL and it is therefore not necessarily up to date. If you require a newer major version than what is available in EPEL, you should use the repository provided by varnish-cache.org.
To use the varnish-cache.org repository, run:
rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release-3.0-1.noarch.rpm
and then run:
yum install varnish
The --no-signature is only needed on initial installation, since the Varnish GPG key is not yet in the yum keyring.
I assume varnishd is in your path. You might want to run pkill varnishd to make sure varnishd isn't running. Become root and type:
$ varnishd -f /usr/local/etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:2000 -a 0.0.0.0:8080
I added a few options, lets go through them:
The -f options specifies what configuration varnishd should use.
The -s options chooses the storage type Varnish should use for storing its content. I used the type malloc, which just uses memory for storage. There are other backends as well, described in :ref:tutorial-storage. 1G specifies how much memory should be allocated - one gigabyte.
Varnish has a built-in text-based administration interface. Activating the interface makes Varnish manageble without stopping it. You can specify what interface the management interface should listen to. Make sure you don't expose the management interface to the world as you can easily gain root access to a system via the Varnish management interface. I recommend tieing it to localhost. If you have users on your system that you don't fully trust, use firewall rules to restrict access to the interface to root only.
I specify that I want Varnish to listen on port 8080 for incomming HTTP requests. For a production environment you would probably make Varnish listen on port 80, which is the default.
Now you have Varnish running. Let us make sure that it works properly. Use your browser to go to http://192.168.2.2:8080/ (obviously, you should replace the IP address with one on your own system) - you should now see your web application running there.
Lets make sure that Varnish really does do something to your web site. To do that we'll take a look at the logs.