HTTP/2 uses a single TCP connection to send multiple streams of data at once so that one resource does not block another resource. HTTP/2 does this by splitting the data into binary coded messages and numbering these messages so the client knows which stream each binary message belongs to.
Whereas HTTP/1.1 loads resource one by one, so if one resource can’t be loaded it will block all other resources behind it.
If you want to enable HTTP/2 on the Apache Web server, you can follow the guide that Bardimin made below.
1. Enabling Apache HTTP/2 Module
As a first step, you need to enable the HTTP/2 module on Apache. Open the file “ httpd.conf ” which is the main configuration file of Apache. If you are using XAMPP, you can find it in “ C:\ xampp \apache\conf\ httpd.conf ”.
Look for ” mod_http2.so ” and uncomment the line by removing the ” # ” sign .
............. LoadModule http2_module modules/mod_http2.so .............
2. Enable HTTP/2 Globally
You can enable the HTTP/2 protocol globally. If you enable it globally, all connections from the Apache Webserver will use that protocol.
To enable it, you just need to add the following directive at the end of the “ httpd.conf ” file or in “ C:\ xampp \apache\conf\ httpd.conf ” if you are using XAMPP.
Protocols h2 h2c http/1.1
3. Enable HTTP/2 on certain Virtual Hosts
Open the file “ httpd-vhosts.conf ” or “C:\ xampp \apache\conf\extra\ httpd-vhosts.conf ” if using XAMPP.
Then add the HTTP/2 protocol to the virtual host configuration:
# Enable HTTP/2 protocol Protocols h2 h2c http/1.1 DocumentRoot "C:\xampp\htdocs\MyWebsiteFolder" ServerName MyWebsite.com SSLEngine on SSLCertificateFile "conf/ssl.crt/server.crt" SSLCertificateKeyFile "conf/ssl.key/server.key" Options All AllowOverride All Require all granted
After all the configuration is complete, save all the configuration files and Restart Apache to see the results.
4. Check if HTTP/2 is running
To check whether your web server is using the HTTP/2 protocol or not, you can use a browser such as Chrome, Firefox, and others.