How to activate HTTP2 on apache2 in Debian 10

You just installed apache2 on debian 10 and you want to activate http2 protocol.

First of all, i recommend disabling the default mod php module and use the more modern way , php-fpm mode.

sudo apt-get install php7.4-fpm
sudo a2dismod php7.4
sudo a2enconf php7.4-fpm
sudo a2enmod proxy_fcgi

Secondly, apache2 comes, by default, with mod prefork , which is not a compatible MPM with http2. I recommend using the mpm_event module.

sudo a2dismod mpm_prefork
sudo a2enmod mpm_event

To make http2 work, you need mod ssl and mod http2 to be activated.

sudo a2enmod ssl
sudo a2enmod http2
sudo systemctl reload apache2

One last step involves adding to the virtual host the following :

Protocols h2 http/1.1
<VirtualHost *:443>
  ServerName example.com
  ServerAlias www.example.com
  DocumentRoot /var/www/public_html/example.com
  SSLEngine on
  SSLCertificateKeyFile /path/to/private.pem
  SSLCertificateFile /path/to/cert.pem
  SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
  Protocols h2 http/1.1
</VirtualHost>

You can check in your browser using the F12 , if the protocol used is HTTP2.