Share via:

Apache: Enabling HTTP/2

This tutorial shows how to enable HTTP/2.0 with Apache.

135 views

Edited: 2019-11-21 06:00

Enabling HTTP/2.0 with the Apache HTTP Server is a very straight forward process. You simply need to enable the http2 module from a command line.

HTTP/2 is the next generation of the HTTP protocol, and it is very useful when you are looking to make use of new features, as well as speed up loading of your pages. The latter is especially true if your page includes a lot of external resources.

1. To install HTTP/2 on your server, all you have to do is run the following command in a terminal:

sudo a2enmod http2

2. Then add the following in: /etc/apache2/apache2.conf:

Protocols h2 http/1.1

3. Finally you may restart the server:

sudo service apache2 restart

See also: Starting, Stopping and Restarting Web-servers in Linux

Checking if HTTP/2.0 is working

If you are working with PHP, you can easily tell what protocol a request was made with via SERVER_PROTOCOL, in the global $_SERVER variable. For example:

echo $_SERVER["SERVER_PROTOCOL"];

The output should be "HTTP/2.0".

Comments