HTTP/2, yes or no?

Is the setting provided by Bernie_O valid for Apache as well?

On apache I enabled it successfully like this:

a2enmod http2
/etc/apache2/conf-available/http2.conf
	<IfModule http2_module>
	  Protocols h2 h2c http/1.1
	  H2Direct on
	</IfModule>
a2enconf http2
service apache2 restart

Here some more about the module and it’s options: https://httpd.apache.org/docs/2.4/mod/mod_http2.html

1 Like

Great! Thanks a lot for your quick reply!
Cheers,
George

For me it does not help at all, needs to follow this procedure and enable php-fpm: https://techwombat.com/enable-http2-apache-ubuntu-16-04/

@gas85
HTTP/2 and php-fpm do not have something to with each other. You can use both separately. I use HTTP/2 with method above successfully via mod-php. But depending on your cloud usage, php-fpm might be a good alternative (is always) anyway.
Of course your Apache version needs to be hight enough to support HTTP/2. But the guide you followed seems to be wrong there, as the official docs say: Available in version 2.4.17 and later: https://httpd.apache.org/docs/2.4/mod/mod_http2.html

Guide: You want to make Apache use the correct PHP implementation: Correct it totally wrong and irritating wording here, as there is no wrong or right in this, it totally depends on your usage and needs. HTTP/2 again works on both.

I started from easy way, then I try everything from this post, but only what I have was Upgrade: h2,h2c in http header, but nothing else.
Since I use php fpm and enable mpm event and proxy_fcgi it works… without it does not work for me…
System is Ubuntu 16.04 with on it Apache 2.4.29.

@gas85
Now I checked again and found this:

Starting from Apache 2.4.27, the Apache MPM (Multi-Processing Module) prefork no longer supports HTTP/2. This will be indicated in your Apache error log as follows:
AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.

Whoopsie, seems you are right for newest apache versions, didn’t know that and don’t know about the reasons yet.
So good to know, from apache 2.4.27 on you need to switch to e.g. mpm_event/php-fpm…

More on this: HTTP/2 guide - Apache HTTP Server Version 2.5

The reason is that mod_h2 is using threads internally. Running Apache in prefork and using h2 can lead to unexpected (and hard to investigate) errors when PHP is also used as a module.

see also: https://github.com/nextcloud/server/issues/4706#issuecomment-310649209

2 Likes

Good to know. I never faced issues with lower Apache version + mod_php + http/2 that time, but there will be a good reason.

To keep using Nextcloud .htaccess for e.g. pretty URLs and some other stuff I stay with mod-php (mpm_prefork) for now, but actually it should be easily possible to move those settings to Apache config/vhost and move o php-fpm (mpm_event).

php-fpm also reads the .htaccess file. The only directives Apache with php-fpm will not understand are the ones that are only available via the php Apache module. e.g. php_value , php_value, php_flag (logical, since the php module isn’t loaded).
However, PHP settings can still be set via the .user.ini file.

There are no changes necessary to the current .htaccess file when using Nextcloud with php-fpm.

If you have a working php-fpm setup, Nextcloud will run out of the box.

Update: Maybe my first sentence is a bit confusing. The .htaccess is read by Apache, not by php-fpm. I meant that it is still read, when php-fpm is used.

2 Likes

Ah thanks for clarification. Seems I mixed things up in my memory since I use both .htaccess and php_(admin_)value.

Since php values can be passed as well via php/fpm pool settings and .user.ini (?) the final benefit of mod-php decreases more and more. For low traffic instances it is at least not significantly slower than php-fpm, but as well not faster (?). The question is if there is any benefit nowadays or if fpm should be always recommended over mod-php?

IMO there’s no reason to use mod-php anymore.

php-fpm is a requirement, if you want to use:

  • a threaded Apache MPM
  • HTTP/2
  • several versions of PHP on the same server
1 Like

Seems so. I will see if I can do some single user access performance and resource usage test on clean machine. On heavy parallel access php-fpm definitely has clear advantage, but I couldn’t find some benchmark on calm server so far.

Just FYI I got this in my Debian update changelog:

apache2 (2.4.25-3+deb9u5) stretch; urgency=medium * This package upgrades mod_http2 to the version from apache2 2.4.33. This fixes a lot of bugs and some security issues, but it also removes the support for using HTTP/2 when running with mpm_prefork. HTTP/2 support is only provided when running with mpm_event or mpm_worker. –

Stefan Fritsch <sf@debian.org> Sat, 02 Jun 2018 09:51:46 +0200

It might also be worth noting that the Apache 2 ITK MPM doesn’t support HTTP/2, this Apache module is great for user seperation on shared servers but Nextcloud on shared servers probably isn’t a great idea…

Jep, this is the case since 2.4.27 (see above).

Hello,

I’m running this setup :
Raspberry
Apache 2.4 - event mpm - php7.3-fpm
MariaDB
Nextcloud 15 (with every recommandations done)

Now i’m wandering if I should enable http2 or not and it seems like it’s not always a good idea (slower ?).
Do some of you find out a way to optimize HTTP2 and to improve their Nextcloud setup ?

Best regards

I’ve try it on Cubietruck and with fpm I have higher CPU Load by PHP, but site opens much (around 1,5 time) quicker in compare to mpm. So, I stayed in fpm with http2 enabled.

I also find that basically my tiny CPU will always being utilized in 100% when I connect to the server. Difference is only in:

  1. By http 1.1 MariaDB will use it more CPU and PHP less,
  2. By http 2.0 PHP will use CPU more and MariaDB less.

At the end Http2.0 shows better results with same CPU utilization for me.

2 Likes

Well, I just tried and it seems to be way better with HTTP2 for now ! What a good news
I have to try that out for a while before I’m able to be sure.

1 Like

I wish that NC really used the new features like Push. It could really speed up things.