How To: Upgrade Apache to HTTP2 on Ubuntu 16.04

How To: Upgrade Apache to HTTP2 on Ubuntu 16.04

Before you begin, most modern browsers only support HTTP2 over SSL so you will need to have migrated to HTTPS first. I’d recommend this excellent tutorial from Digital Ocean using the free CA Let’s Encrypt to do this in a matter of minutes.

The version of Apache bundled with Ubuntu 16.04 doesn’t come with the HTTP2 module, as is probably correct for an LTS version. Luckily, for those of us who don’t want to switch to NGINX but still want the latest features, it’s very simple to install the version from Apache that includes this. All we need to do is add the repository for the latest version of Apache, install the new version and enable the module.

First, let’s add the repository and update the package list:

sudo add-apt-repository ppa:ondrej/apache2
sudo apt-get update

Now, upgrade all installed packages to the latest version, then run dist-upgrade to fetch Apache from the new repository.

sudo apt-get upgrade
sudo apt-get dist-upgrade

Now we have the latest version of Apache installed, all that’s left is to enable the module and tell Apache to use HTTP2 when available.

sudo a2enmod http2

Then, edit the apache.conf file:

sudo nano /etc/apache2/apache2.conf

And add the following line to enable global support for HTTP2

Protocols h2 http/1.1

Now just restart Apache and you’re all set!

sudo service apache2 restart

You can test your server here: https://tools.keycdn.com/http2-test

Leave a Reply

Your email address will not be published. Required fields are marked *