It is important to setup HTTP2 in Apache web server to improve speed and performance. HTTP/2 supports parallelism, header compression, binary data transfer, and also server push. In this article, we will look at how to enable HTTP2 in Apache web server.
How To Enable HTTP2 in Apache
Here are the steps to enable HTTP2 in Apache web server. Please note, HTTP/2 is supported for HTTPS/SSL websites only. So please enable SSL in Apache web server before proceeding.
1. Enable http2 module
Open terminal and run the following command to enable http2 module.
$ sudo a2enmod http2
Apache configuration file is located at one of the following locations, depending on your Linux distribution.
Open terminal and run the following command to open Apache configuration page.
$ sudo vi /etc/httpd/conf/httpd.conf
Look for the following line
#LoadModule http2_module modules/mod_http2.so
Uncomment it by removing # at its beginning.
LoadModule http2_module modules/mod_http2.so
Also read : How to Enable Apache Server Status dashboard
2. Add Protocols directive
Also add the following line to your Apache server configuration file. This needs to be done for both Ubuntu/Debian as well Redhat/CentOS linux.
Protocols h2 h2c http/1.1
Add the above line to Apache server configuration file. If you have setup virtual host in Apache, then open your virtual configuration file and add the above line in <VirtualHost *:443> tag.
Also read : How to remove x-powered-by in Apache/PHP
3. Restart Apache Web Server
Restart Apache web server to apply changes.
# service httpd restart OR # systemctl restart httpd OR # sudo service apache2 restart
Also read : How to Disable HTTP OPTIONS methods in Apache
4. Verify HTTP/2
Use a third party tools like KeyCDN HTTP2 checker that allow you to check if HTTP/2 is enabled on your website.
After you enter your website, with HTTPS URL, it will tell you if HTTP/2 is enabled in it or not.
As you can see, it is quite easy to enable HTTP/2 in Apache.