Learn how to Install HAProxy on Ubuntu 20.04.
Ubuntu 20.04 is a great choice for installing your HAProxy software load balancer. It’s a free Linux operating system that’s fast, secure, and best of all, it’s easy to use.
One of the features that makes Ubuntu so accessible to even the newest of users is its package manager,
apt, the Advanced Packaging Tool.
apt lets you easily install and remove packages and dependencies, generally without having to worry about the nitty-gritty details of file paths, libraries, compilers, and version conflicts.
It’s so easy that installing HAProxy on a brand new Ubuntu box can be as simple as a one-line
But wait, there’s more!™
Yes, that simple command will quickly and easily set you up with HAProxy, but you’ll find that the version you’ve just installed probably lags behind the current release by a minor version number or two, sometimes as much as a major version number.
The version you get with
apt out-of-the-box will be stable and secure, but it’s going to lack some of the cool new features you’ve been reading about, such as FIX protocol support, HTTP/2 WebSockets, or Dynamic SSL Certificate Storage.
You can compile the source code yourself, but that can be a lot of extra steps. Fortunately, Vincent Bernat has done all of the hard work and released something called a PPA, or Personal Package Archive. A custom PPA tells Ubuntu to use a software source outside its normal channels and install a custom package. In the case of HAProxy, which is already provided by the official sources, once the PPA is installed,
apt will use this custom package over the default.
Install the latest HAProxy using a PPA
Install Ubuntu 20.04 Server. For testing, I’m using a virtual machine running on my laptop. Everything we do here should work equally well on bare metal or any cloud provider.
Head over to haproxy.debian.net, where you can select the install instructions for your OS. At the time of this writing, the latest version was 2.4. Select the options for Ubuntu Focal (20.04 LTS) (long term support) and HAProxy 2.4-stable (LTS). This will bring you to a page listing the commands you need to run:
The first command installs the software-properties-common package which helps you manage any PPAs you install. It’s probably already installed, but running it again ensures that it’s available. The second command puts the PPA into the list of software sources.
We’re now ready to install the very latest HAProxy:
=2.4.\* to the end tells
apt that we want to maintain the latest version of HAProxy in the 2.4 branch, so if there are future updates in that branch, you’ll get them when you do an
apt upgrade .
To show what you’ve installed:
Do an update and upgrade, to ensure you have the latest software packages and any security fixes:
You now have a fully up-to-date Ubuntu system running the latest version of HAProxy with a stock configuration located at /etc/haproxy/haproxy.cfg; you’re ready to start customizing.
On the HAProxy blog, head over to HAProxy Configuration Basics: Load Balance Your Servers. It will walk you through the steps to balance your traffic like a pro.
In this post, you learned how to install the open-source edition of HAProxy on one of the most popular and most powerful operating systems around, Ubuntu 20.04. You installed a custom PPA, or Personal Package Archive, to give you complete control over the version, ensuring that future updates remain within your desired branch.
HAProxy Enterprise is the world’s fastest, and most widely used software load balancer. It powers modern application delivery at any scale and in any environment, providing the utmost performance, observability, and security for your critical services. Organizations harness its cutting edge features and enterprise suite of add-ons, which are backed by authoritative, expert support and professional services. Ready to learn more? Sign up for a free trial.Want to know when more content like this is published? Subscribe to our blog or follow us on Twitter. You can also join the conversation on Slack.