How to enable HTTP2 in Apache

  1. Why should you move to HTTP2
  2. How to enable HTTP2 support in Apache

Why you should move to HTTP2

Because HTTP 1.1 was drafted 18 years ago. No further comments needed 🙂 the web evolved, so the HTTP protocol needs to evolve to keep up with security advancements, speed and efficiency. And so it does the improvements of the protocol are HUGE. Just to name a few:

  • It supports multiple requests at the same time(Multiplexing), on HTTP 1.1 requests were blocking, meaning a transfer have to wait for other transfer to complete in order to start.
  • Another massive improvement is the ability to send resources to the client before he requested them(Server Push) so the user doesn’t have to wait the load time when he needs the resource.
  • One connection to the server is used to load all resources from a website instead of multiple TCP connections.
  • Header delivery is optimized by using HPACK compression to reduce overhead

Keep in mind however that most used browsers only support HTTP2 over SSL, So go ahead and setup that Let’s encrypt certificate first!

How to enable HTTP2 support in Apache

If you have Apache 2.4.* enabling HTTP2 will be very easy. However if you don’t you have to update your web-server first. How to update your web-server on Ubundu/Debian/Mint:

After the above commands you will now be proud owner of a server running Apache 2.4.29 or above. Now you have to enable the HTTP2 module using the following command:

Now in order to take advantage of the HTTP2 upgrade you have to add “Protocols h2 http/1.1” to the needed vhosts. They should look similarly to this one:

After the modifications are done, reboot/reload Apache using “sudo service apache2 restart” and enjoy the boost!

About Pavel Petrov 2 Articles |  18 How-tos
Pavel is a senior developer for the last 7 years, with extended interest in Linux administration, WordPress and Symfony.

Be the first to comment

Leave a Reply

Your email address will not be published.


*