How to Compile Apache with mod_http2, mod_ssl

How to Compile Apache with mod_http2, mod_ssl

HTTP/2 was released in 2015 and it is the second major HTTP protocol. Since the time of launch, it supports around 11% of the websites. The HTTP/2 has many features like

1) HTTP Header Compression

2) Push Technologies

3) Load page elements in parallel over single TCP connections

4) Binary protocol

5) Reduce Latency

Studies show that HTTP/2 is two times faster than HTTP/1.1. Litespeed was one of the first web servers to support HTTP/2. Currently, all browser support HTTP/2 protocol over HTTPS only. Your web server must be configured with SSL certificate to support HTTP/2. The only dependency which stands before this process is the version of Apache. It can only be deployed in Apache HTTP 2.4.17 or higher version with the help of mod_http2 module. So if you have 2.2 or lower version then first you have to upgrade to a compatible version. Now let’s have a look at the process of enabling HTTP/2.

1) Download and extract the httpd.

# tar –xvf  httpd-2.4.25.tar.gz


2) After the extraction, you can see a folder “create” inside that and build the Apache from source with configuring command.

# ./configure –enable-ssl –enable-so –enable-http2


3) Run the below-mentioned command to ensure that there are no errors in the above step.

# echo $?


4) Now execute the following “make” command to proceed further installation.

# make

# make install


5) This concludes Apache HTTP is installed with HTTP/2 module and it’s time to do the essential configurations required.

Take a backup of httpd.conf file (default location /etc/httpd/conf/httpd.conf)

Open the httpd.conf file with your favorite text editor and make the following directive exist in it, if not then add it.

“LoadModule http2_module modules/”


6) Next, you have to add the protocols directive like mentioned below.

“Protocols h2 h2c http/1.1” – there are three protocol directives in this.

  • h2 – instructing Apache to support HTTP/2 protocol over SSL/TLS
  • h2c – instructing Apache to support HTTP/2 over TCP
  • http/1.1 – if the client doesn’t accept HTTP/2 then serve the request over HTTP/1.1

If you are enabling HTTP/2 for an individual virtual host, then you need to add Protocols under respective Virtual Host.


7) You have to restart Apache to get reflected by the HTTP/2 configuration.

# /etc/init.d/httpd restart

Now, Apache HTTP instance is enabled to support HTTP/2 protocol.


If you need any further help please do reach our support department.