Apache2: How to Enable HTTP/2 on Ubuntu 16.04

Submitted by admin on Thu, 01/05/2017 - 17:10

HTTP/2 has been supported since Apache 2.4.17. I tried sudo a2enmod http2 on this Ubuntu 16.04 host, however it said ERROR: Module http2 does not exist!. Looks I needed to upgrade Apache2 as follows:
sudo add-apt-repository -y ppa:ondrej/apache2
sudo apt-key update
sudo apt-get update
sudo apt-get --only-upgrade install apache2 -y

Select Y (Note that this will overwrite your current configuration; therefore do backup of apache2.conf if necessary.
*** apache2.conf (Y/I/N/O/D/Z) [default=N] ?

press Y both the times and proceed.
Check your mods-available folder you will see http2.load file:

sudo a2enmod http2

sudo vi /etc/apache2/apache2.conf

Add the following one line to the bottom of the file
Protocols h2 http/1.1

Then, restart Apache2.
sudo systemctl restart apache2