Forum Moderators: phranque

Message Too Old, No Replies

Updating to HTTP/2

         

csdude55

1:51 am on Nov 20, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've read the official info on it, but I have a ton of questions:

[httpd.apache.org...]

My current server runs CentOS 6 and MySQL 5.5. I've moved most of my sites to PHP 7.x, but my main site (the highest traffic site) uses MySQL so I've had to set it to use PHP 5.6. I'm working on a rebuild that uses MySQLi, though, so I can make it use 7.x, too.

It's my understanding that HTTP/2 doesn't work with DSO handlers, and I'm using PHP 5.6 as DSO. I honestly don't know if I could/should change it to CGI? I feel like this is just how it was originally set up.

So I guess my first question is, can I safely install it and use it on all of the other sites, but not the one that uses PHP 5.6?

I understand that installing HTTP/2 is theoretically "faster", but I don't really understand the context or if there have been any side-by-side benchmark comparisons. So I don't know if "faster" means "your website pages and files will load faster", or "Apache processes will open and close faster, so there's no noticeable difference to the user but less stress on the server"?

So my second question is, is there any reason for me to NOT install it?

If I'm reading things correctly, I simply need to install Apache modules mod_http2 and libnghttp2. That's easy enough in EasyApache 4...

But it also says:

When you ./configure you Apache httpd source tree, you need to give it '--enable-http2' as additional argument to trigger the build of the module.

Ok... where does one "give it '--enable-http2'?

And then:

Basic Configuration
When you have a httpd built with mod_http2 you need some basic configuration for it becoming active. The first thing, as with every Apache module, is that you need to load it:

LoadModule http2_module modules/mod_http2.so

The second directive you need to add to your server configuration is

Protocols h2 http/1.1

This allows h2, the secure variant, to be the preferred protocol on your server connections. When you want to enable all HTTP/2 variants, you simply write:

Protocols h2 h2c http/1.1

Depending on where you put this directive, it affects all connections or just the ones to a certain virtual host. You can nest it, as in:

Protocols http/1.1
<VirtualHost ...>
ServerName test.example.org
Protocols h2 http/1.1
</VirtualHost>

This allows only HTTP/1 on connections, except SSL connections to test.example.org which offer HTTP/2.

Does this mean that I need to modify /etc/apache2/conf.d/http2.conf and add the LoadModule command? It currently only has this (since 2017):

<IfModule http2_module>
LogLevel http2:info
Protocols h2 h2c http/1.1
</IfModule>


So maybe I ONLY need to modify the VirtualHost (or, more accurately, /etc/apache2/conf.d/userdata/ssl/2_4/[account]/[domain_name]/httpd.conffor the sites that use PHP 5.6 to Protocols http/1.1 to overwrite the default protocol?

robzilla

3:57 pm on Nov 20, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So I don't know if "faster" means "your website pages and files will load faster", or "Apache processes will open and close faster, so there's no noticeable difference to the user but less stress on the server"?

Both parties benefit. HTTP/2 employs a technique called multiplexing, among other things, which allows it to use a single connection to process multiple requests simultaneously. See this image [blog.cloudflare.com] from Cloudflare for a comparison. As a result, there will be less overhead on both the user and the web server side in processing the same number requests as before. Try a demo: [http2.akamai.com...]

Ok... where does one "give it '--enable-http2'?

On the command line when you're building Apache from source, which is not what you're doing. Simply enable it in EasyApache 4.

So maybe I ONLY need to modify the VirtualHost (or, more accurately, /etc/apache2/conf.d/userdata/ssl/2_4/[account]/[domain_name]/httpd.conffor the sites that use PHP 5.6 to Protocols http/1.1 to overwrite the default protocol?

Correct.

JorgeV

11:14 am on Nov 21, 2020 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



Hello,

Just in case, I'd like to bring your attention on the fact that HTTP/2 requires a TLS connection. (https). So all your sites, need to come with a TLS certificate.