Enable HTTP2 in Apache on Ubuntu 16.04

May 11, 2016 4.7k views
Apache Server Optimization Ubuntu 16.04

Hi there,

I've recently created a new droplet with Ubuntu 16.04 and was pleased to see that sudo apt-get install apache2 gets me Apache 2.4.18. I was hoping that would allow me to enable HTTP2 support; alas, the respective mod_http2 is not included. Is there any way to manually install the module or to get a version of Apache that has it included?

Many thanks,

2 Answers
BriarMoonDesign July 24, 2016
Accepted Answer

Another option is using Ondrej's Launchpad PPA.
For example: (replacing REPOSITORY with string from that page for your Ubuntu version).

sudo add-apt-repository 'REPOSITORY'
sudo apt-get update
sudo apt-get dist-upgrade

This will give you the latest Apache rather than the version specifically for Ubuntu. Of course there are reasons Ubuntu ships slightly differently - stability, known degree of security/performance testing etc. but in my mind it is a worthwhile tradeof especially for HTTP/2

  • Thank you very much, that is a great solution. Ondrej's repository works like a charm. I agree with you that it's worth to make the tradeoff in terms of stability if you consider the vast improvements of HTTP2.

    Don't forget that after installing the new version of Apache, you need to activate the module manually:

    sudo a2enmod http2

    In your Apache config file, you can either add global support:

    Protocols h2 h2c http/1.1

    Or you can activate it for individual, secure vhosts:

    Protocols h2 http/1.1

    Restart Apache and you're all set. You can test your server at https://tools.keycdn.com/http2-test.

Hi Florian,

I'm not sure if Ubuntu decided to include HTTP/2 support in 16.04's Apache packages because HTTP/2 support is still considered experimental in Apache.

Instead, you might try using ServerPilot which enables HTTP/2 in Nginx and configures your server with Nginx as a reverse proxy in front of Apache so that you can still use Apache just like normal with .htaccess files and such. Your code never knows that Nginx is there and you get the benefits of Nginx's scalability, handling slow clients, and HTTP/2 support.


I hope that helps.

  • Thanks a lot, that's a much more detailed response than I could have possibly hoped for in that short amount of time. I will definitely give it a shot. Very helpful indeed!

Have another answer? Share your knowledge.