Report this

What is the reason for this report?

Enable http2 in apache

Posted on July 17, 2019

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



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!

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.

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/

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.