Question

Enable HTTP2 in Apache on 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, Florian

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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

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.

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.

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

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)

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?

Namaskara, Krishna

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

Namaskara, Krishna.

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

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.

Namaskara, Krishna

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.

https://serverpilot.io/community/articles/http2-is-enabled-for-your-ssl-websites.html

I hope that helps.