First of all make sure that the following 3 requirement is fullfilled:
- A registered domain name with working HTTPS (TLS/SSL). HTTP/2 only works alongside HTTPS because most browsers, including Firefox and Chrome, don’t support HTTP/2 in cleartext (non-TLS) mode.
- Also you need at least Apache version 2.4.24
- If you run PHP in Apache via mod_php, you need to switch to FPM. That is not a bad thing. FPM is newer and faster.
Now lets do the configuratoin for HTTP/2
Switching Apache’s PHP Module from MPM Prefork to Event
Run the following commands:
sudo apt-get install php7.2-fpm sudo a2enmod proxy_fcgi sudo a2enconf php7.2-fpm sudo a2dismod php7.2 sudo a2dismod mpm_prefork sudo a2enmod mpm_event sudo service apache2 restart
Installing and Enabling HTTP/2 in Apache
Enable the module mod_http2:
sudo a2enmod http2 sudo service apache2 restart
Enable the HTTP/2 protocol by adding the following to /etc/apache2/apache2.conf:
Protocols h2 http/1.1
Verify that HTTP/2 is Working
Cloudflare put together a comprehensive list of ways you can check a website for HTTP/2 support. The easiest to use are probably Chrome Dev Tools (network view, add the Protocol column) or the online test from KeyCDN.