How to install Varnish cache on CentOS, Ubuntu and Debian
How to install Varnish cache on CentOS, Ubuntu and Debian
I started long ago an article that stated I was using Varnish cache for one of my servers, which is true, but never caught my mind to make an article on how to install Varnish on CentOS or Ubuntu or Debian. You’ve probably noticed, but these 3 are one of the 3 OS’s on VPSs clients I’ve seen so far so this is why I’m mostly making tutorials for these 3 operating systems. Anyway, let’s get to our main topic and show you how to install Varnish cache on CentOS, Ubuntu and Debian. I’ll try to go in detail as much as possible with each one. Keep in mind, Varnish cache has been designed from ground up to be a reverse cache proxy server!
Install Varnish cache on Ubuntu, Debian
Ubuntu and debian mostly have the same process to install almost any software package, this includes varnish cache. Normally it should be present on Ubuntu, you can easily check this on both by using the command:
1 |
apt-cache search varnish |
This should let you know if you can install varnish as it is. Else you need to get the repositories first:
1 2 3 4 |
curl http://repo.varnish-cache.org/debian/GPG-key.txt | apt-key add - echo "deb http://repo.varnish-cache.org/debian/ wheezy varnish-3.0" >> /etc/apt/sources.list apt-get update apt-get install varnish |
This will work on both Ubuntu and Debian installations. Keep in mind however that for Debian, you will need to change wheezy to squeeze or vice versa, depending on which version you are using. To be sure which one is the distribution you need to use, you can use the command:
1 |
lsb_release -a |
This will return the result similar to:
1 2 3 4 5 |
No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 7.1 (wheezy) Release: 7.1 Codename: wheezy |
So in my case, I’m using wheezy as my Debian version. That’s it for Debian and ubuntu, its not that hard, but on Debian you need to be careful at the code name you are using for your distribution.
Install Varnish cache on CentOS
On CentOS operating system we are currently going to install it on two version, CentoOS 5 and CentoOS 6. While version 5 is getting less and less support, it is still being used a lot on the internet, hence why I’ll go through both showing you how to install it.
- Centos 5 – run the below command to install the repository for varnish
1 |
rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release/varnish-release-3.0-1.el5.centos.noarch.rpm |
- Centos 6 – run the below command to install the repository for varnish
1 |
rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el6/noarch/varnish-release/varnish-release-3.0-1.el6.noarch.rpm |
After the repository for each version is installed, you can then run the installation of varnish:
1 |
yum install varnish |
And that’s about it for installing varnish, in my next toturials I’ll go through the process of configuring it for you and showing you how to adjust the cache based on each case.
Don’t forget to subscribe and comment below if I missed anything.