30-04-2021



Apache version 2.4.17 introduced HTTP/2 support. If your server is running Apache version below this version, you need to upgrade Apache to the latest version first. Please note that the modhttp2 module is rather new, but is finally marked stable. There have been multiple reported security vulnerabilities in 2016 and 2017. Gentoo, strangely enough, mostly refers to it as apache - but config files have httpd in the naming conventions. The application's development is managed by the Apache Foundation. Its name is actually Apache HTTP Server. It is often also called Apache httpd (http daemon) by the Apache. Add source URIs. Add source URIs to the sources.list file if it is not already done so: vi. Apache Traffic Server™ software is a fast, scalable and extensible HTTP/1.1 and HTTP/2 compliant caching proxy server. Formerly a commercial product, Yahoo! Donated it to the Apache Foundation, and currently used by several major CDNs and content owners.

  1. Http2 Apache2 Setup
  2. Http2 Apache2 Install
  3. Apache2 Http2 Enable
  4. Enable Http2 Apache
  • Based on https://gist.github.com/GAS85/990b46a3a9c2a16c0ece4e48ebce7300
  • This totorial is for an older Ubuntu 18.04, for a Ubuntu 20.04 please read here --> https://gist.github.com/GAS85/38eb5954a27d64ae9ac17d01bfe9898c
  • A self-managed VPS or dedicated server with Ubuntu 18.04 running Apache 2.4.xx.
  • A registered domain name with working HTTPS (TLS/SSL). HTTP/2 only works alongside HTTPS because most browsers, including Firefox and Chrome, don’t support HTTP/2 in cleartext (non-TLS) mode.

Step 1: Install Apache2

Per default it will be apache2 version 2.4.29 what is enought for http2 support.

Step 2: Tell Apache to use PHP FastCGI

You want to make Apache use a compatible PHP implementation by changing mod_php to php-fpm (PHP FastCGI). If your website or app breaks on FastCGI, you can always revert back to mod_php until further troubleshooting.

Install PHP FastCGI module for PHP 7.2, it is default version for Ubuntu 18.04

Enable required modules, proxy_fcgi and setenvif:

Enable php7.2-fpm:

Disable the mod_php module:

Http2 Apache2 Setup

Restart Apache:

Step 3: Change MPM from 'prefork' to 'event'

Since the default 'prefork' MPM (Multi-Processing Module) is not fully compatible with HTTP/2, you’ll need to change Apache’s current MPM to 'event' (or 'worker'). This is shown by the error message in Apache versions greater than 2.4.27 as – AH10034: The mpm module (prefork.c) is not supported by mod_http2.

Keep in mind that your server requires more horsepower for HTTP/2 than for HTTP/1.1, due to the multiplexing feature and other factors. That said, smaller servers with low traffic may not see much difference in performance.

First, disable the 'prefork' MPM:

Enable the 'event' MPM:

Restart Apache2 and PHP 7.2:

Step 4: Add a line to your Virtual Host file

Http2 Apache2

Add the following line to your site’s current Virtual Host config file. This can go anywhere between the ... tags. If you want to serve HTTP/2 for all your sites, add this to your global /etc/apache2/apache2.conf file instead of per each individual site’s Virtual Host file.

Http2 Apache2 Install

Explanation: h2 is TLS-encrypted HTTP/2, h2c is cleartext HTTP/2, and http/1.1 is ordinary HTTP/1.1.

Having http/1.1 at the end of the line provides a fallback to HTTP/1.1, while h2c is not strictly necessary.

Step 5: Enable the mod_http2 Apache module

Now you can enable the http2 module in Apache:

Check Apache2 config and if no errors, restart Apache:

Step 6 create http2.conf for entire Server HTTP2

Create a new http2.conf

and add all the following rows:

Enable the http2.conf by running

Check Apache2 config and if no errors, restart your Apache2

and enhance your ssl-vhost file (default-ssl.conf):

Amend in your configuration file:

P.S. All in one command (you still have to edit your VirtualHost and ssl config):

The Apache HttpComponents project is responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols.

This project functions under the Apache Software Foundation (http://www.apache.org), and is part of a larger community of developers and users.

HttpComponents Overview

The Hyper-Text Transfer Protocol (HTTP) is perhaps the most significant protocol used on the Internet today. Web services, network-enabled appliances and the growth of network computing continue to expand the role of the HTTP protocol beyond user-driven web browsers, while increasing the number of applications that require HTTP support.

Designed for extension while providing robust support for the base HTTP protocol, the HttpComponents may be of interest to anyone building HTTP-aware client and server applications such as web browsers, web spiders, HTTP proxies, web service transport libraries, or systems that leverage or extend the HTTP protocol for distributed communication.

HttpComponents Structure

HttpComponents Core

Apache2 Http2 Enable

HttpCore is a set of low level HTTP transport components that can be used to build custom client and server side HTTP services with a minimal footprint. HttpCore supports two I/O models: blocking I/O model based on the classic Java I/O and non-blocking, event driven I/O model based on Java NIO.

HttpComponents Client

HttpClient is a HTTP/1.1 compliant HTTP agent implementation based on HttpCore. It also provides reusable components for client-side authentication, HTTP state management, and HTTP connection management. HttpComponents Client is a successor of and replacement for Commons HttpClient 3.x. Users of Commons HttpClient are strongly encouraged to upgrade.

Commons HttpClient (legacy)

Enable Http2 Apache

Commons HttpClient 3.x codeline is at the end of life. All users of Commons HttpClient 3.x are strongly encouraged to upgrade to HttpClient 4.1.