Question

Enable http2 in apache

Hi, I tried to enable http2 with apache2 but I couldn’t. I did this:

  • I activated http2 with this: sudo a2enmod http2
  • I added this line in my virtual host with 443 port: Protocols h2 http/1.1.

I have a ubuntu server 18.04.2 and apache 2.4.29, also i use letsencrypt for the site.

I need to do something else?

Thanks


Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello,

That should be pretty much it.

You can now use your browser to check if the resources are actually going through http2. You can do that with the browsers developer tool, then go to the networking tab and try accessing your site, there you should see the protocol that is being used.

Note that the Protocol column might not be there, so you need to enable it, just right click on any of the other columns and choose tick the Protocol from the drop down.

Let me know how it goes! Bobby

For anyone looking for a solution to this, I had the same issue and followed the steps here, thanks to the discussion here, lead me in the right direction:

sudo apt install php7.4-fpm
sudo a2enmod proxy_fcgi
sudo a2enconf php7.4-fpm
sudo a2dismod php7.4
sudo a2dismod mpm_prefork
sudo a2enmod mpm_event
sudo service apache2 restart

Then enabling the Apache module (as the OP had done):

sudo a2enmod http2
sudo service apache2 restart

Then adding this config line to your vhost configs (as the OP had done):

<VirtualHost *:443>
  Protocols h2 http/1.1
  .... 
</VirtualHost>

Source: https://helgeklein.com/blog/2018/11/enabling-http-2-in-apache-on-ubuntu-18-04/