How to enable HTTP/2.0 in Apache

不言
不言Original
2019-03-30 14:01:375350browse

This article introduces you to enabling HTTP/2.0 in the Apache Web server on CentOS/Red Hat/Debian and Ubuntu systems. Let’s take a look at the specific content.

How to enable HTTP/2.0 in Apache

HTTP/2 (HTTP/2.0) is a major upgrade from the older version of the HTTP/1.1 protocol. HTTP/1 was released in 1997 and after a long time, HTTP/2 was released in 2015. The HTTP/2 protocol is based on SPDY (often called speedy). Some of the major updates to HTTP/2 are:

Server push: The server will proactively send components to the client, so the client does not need to wait for a request to be sent to the server.

Multiplexing: Reduce the number of active connections by bundling multiple HTTP requests from the client and to the server.

Encryption: Efficiently use the TLS protocol in HTTP/2 for encryption over HTTP/1.1.

HTTP header compression: Compressing headers will reduce the overhead of additional requests to the web server.

Install or update Apache

The Apache version supports the HTTP/2 protocol>=2.4.17. Therefore, make sure your version of Apache supports the HTTP/2 protocol. If Apache is not installed yet or you are still using an older version, you need to upgrade it first. Use the following command to add the ppa to install the latest Apache2 version on your Ubuntu system.

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:ondrej/apache2
$ sudo apt-get update
$ sudo apt-get install apache2

Verify Apache Version

After successfully installing the Apache2 web server on your system, please ensure that Apache>=2.4.17, earlier versions do not support the HTTP/2 protocol .

$ apache2 -v

Server version: Apache/2.4.17 (Ubuntu)
Server built:   2015-11-05T00:00:00

Enabling HTTP/2 in Apache

The HTTP/2 protocol requires an SSL/TLS virtual host. Without an SSL/TLS-enabled website, the HTTP/2 protocol cannot be used. Now edit your website virtualhost and add http2 keyword in the listen section.

$ sudo a2enmod http2
$ sudo service apache2 restart

Verify HTTP/2

Configure a virtual host with SSL for your domain.

This article has ended here. For more other exciting content, you can pay attention to the Linux Video Tutorial column on the PHP Chinese website!

The above is the detailed content of How to enable HTTP/2.0 in Apache. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn