We won't be just installing any version of Varnish, it will be a specific one: Varnish Cache 6.0 LTS. As the LTS indicates, it's the long-term supported and stable version of Varnish. It's still open source, but it's not maintained by the open-source community. It's maintained by us at Varnish Software, and we provide frequent bug fixes and also feature backports from the upstream versions.
How to install Varnish on CentOS and Red Hat Enterprise LinuxIf you're planning to install Varnish on a CentOS 8 system or a Red Hat Enterprise Linux 8 system, run the following command to disable the local Varnish module:
sudo dnf module disable varnishYou will then source the etc os-release file, which will make some operating system related variables available:
If you're using CentOS, install the epel-release package using the following command. It will make dependencies required by the Varnish installation, available.
sudo yum install epel-release
However, if you're using Red Hat Enterprise Linux, the epel-release package won't be available locally, so you'll need to fetch it from a remote RPM package of which the end point contains a version ID string. That represents the version of your operating system. If you're using Red Hat Enterprise Linux 8 or CentOS 8, this will be devalued.
sudo yum install https://dl.fedoraproject.org/pub/
Now it's time to register the package repository. We do this by adding the following configuration to a specific repo file that is read by the yum package manager:
sudo tee /etc/yum.repos.d/
varnishcache_varnish60lts.repo > /dev/null <<-EOF
It contains the URL of our package repository, which has some variables that need to be parsed. In the example above, a 64 bit x86 system running on Enterprise Linux 8 would be the string.
Once we have the location of our package repository in order, and the yum package manager is aware of that, it's simply a matter of calling yum install varnish to install Varnish, with all it's dependencies.
sudo yum install varnish
Even though we've installed Varnish, our work is not done yet. We need to enable the system V service for Varnish. This will ensure Varnish automatically gets restarted after a server reboot.
sudo systemctl install varnish
After enabling the system V service for Varnish, we now have to edit it:
sudo systemctl edit --full varnish
An editor will open and present us with full service including varnishd runtime parameters. We do this because we want to modify some of these parameters:
-a :80 \
-a localhost:8443,PROXY \
-p feature=+http2 \
We want to change the listening port from 6081 to 80, and we want to upgrade the allocated memory from 256 megabytes to 2 gigabytes.
After performing these changes, save the file, exit the editor and your configuration is set. The only thing we need to do is sudo systemctl restart varnish.
sudo systemctl restart varnish
Now you know how to install a supported and stable version of Varnish on CentOS and Red Hat Enterprise Linux systems. Stay tuned for next week's episode where we'll dive into Varnish Cloud.