How to enable HTTP/2

Ubuntu Linux 20.04.2

I am struggling to make http/2 work.
I have enabled http2 in webmin / servers / apache webserver / global configurations / configure apache modules
Added

Protocols h2 http/1.1

to hosts file.
Restarted apache - it does not work.
Switched between fcgi and fpm, nothing.
How can I make http2 work?

Seems like it need to disable mpm_prefork but but I can’t enable php7.4 if I select either mpm_event or mpm_worker.
Any suggestions?

Is the http2 module enabled and is mod_php disabled?

By “hosts file” you mean an Apache virtualhost file, right? Placing the protocols line at the bottom of your main Apache config should work server-wide. I don’t think it needs to be inside a <VirtualHost> block.

http2 is enabled
I don’t see a mod_php in webmin / servers / apache webserver / global configurations / configure apache modules, but there is a php7.4 that is enabled and if I disable that, I am able to enable mpm_event or mpm_worker but the websites don’t work. If php7.4 is enabled then mpm_prefork is enabled too and it won’t let me chose mpm_event or mpm_worker, but I see posts saying that mpm_prefork does not support http2 anymore and one of the other modules must be enabled instead. I am not clear however if php7.4 should be enabled along them or disabled, the websites break if it is disabled and it won’t let me enable it with anything other than prefork
Yes I added the protocols in every virtualhost file for each site but not inside the apache main config.
I can change it to the main apache config.

Glad http/2 is working. Your issues are cascading so you might want to start a new post with an appropriate title about PHP.

It is not working.
Sorry if my post was confusing but HTTP2 is not working. The module is enabled but when checking from the browser HTTP2 is not working it still says HTTP 1.1

I have notions about what’s wrong… The http2 Apache module may or may not be enabled. A common problem that comes up in these forums is that the mod_php Apache module still loads when it needs to be disabled. And it’s easy to overlook SSL. Then there’s PHP-FPM to consider.

I don’t use Ubuntu but there’s no shortage of Ubuntu help. Try comparing this tutorial to this one and maybe others. As long as you don’t mind working in a terminal I think you’ll end up with a broader picture of what’s needed to get it all working.

Wow :astonished:
Thank you!!!
The first tutorial did it for me.
Where I was going wrong was I was trying to restart apache in webmin and it was not turning on, while not giving me any errors.
When I tried to restart apache in terminal it told me there were errors which I then tracked to the sites-enabled config files containing php_admin lines that needed to be commented out. Had to go through them one by one then a2dissite and a2ensite each of them (please someone let me know if there’s an easier way to do this through virtualmin).
Once that was all done I was able to restart apache and HTTP2 is now working.

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.