Enable HTTP2 in Apache on Ubuntu 16.04

May 11, 2016 24.5k 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,

10 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!

root@misg:~# apt-get update
E: Malformed entry 57 in list file /etc/apt/sources.list (URI parse)
E: The list of sources could not be read.

root@misg:~# apt-get dist-upgrade
E: Malformed entry 57 in list file /etc/apt/sources.list (URI parse)
E: The list of sources could not be read.
E: Malformed entry 57 in list file /etc/apt/sources.list (URI parse)
E: The list of sources could not be read.

I am getting these errors. Please help.


a2enmod http2
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LCALL = (unset),
CTYPE = "UTF-8",
LANG = "enUS.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en
ERROR: Module http2 does not exist!

I think I was able to succeed enabling HTTP2 after following from the other tutorials. Thanks, though!


  • That's good to hear. Sorry I couldn't get back to you earlier.

    • Now, I am having a different problem. Wordpress - Permalinks issues. I am not able to customise the page (permalinks). I know this is not relevant in this article but just thought of seeking your help.


      • I think this is a topic that has been written about extensively and I'm almost sure there's somebody who's already dealt with your problem.

        If you don't find anything, could you please just open a seperate thread, for clarity's sake?

Namaste Folks, I was able to enable HTTP2, and recently it got switched to HTTP 1.1
Any idea why this could have happened? I am still trying to figure out how to reverse this?


sudo add-apt-repository ppa:ondrej/apache2
sudo apt-get update
sudo apt-get install apache2 -y
sudo a2enmod http2
Put somewhere this directive → Protocols h2 http/1.1
sudo service apache2 restart

From the Source Vide (https://youtu.be/8OM_eqRAsMM)

I have tried all above, however, it still says HTTP 1.1 and there's a certain Upgrade: h2. What does it mean?

Please try if you know what you are doing. Neither Ubuntu nor other UNIX platforms support out of the box HTTP2 protocols. It is not recommended to run HTTP2 with these configurations on the production server unless you want to play along with it.

It was working fine for me but when I updated it recently it rolled back to HTTP 1.1, so I am looking out for answers who knows how to resolve this.

Have another answer? Share your knowledge.