HTTP/2, yes or no?
listen 443 ssl;
listen 443 ssl http2;
You need nginx >= 1.9.5

@ Bernie_O,

Is that all we need?


thats all is need to enable http/2. SSL is necessary for HTTP/2 to work. Browsers dont use HTTP/2 if SSL is not enabled

Thanks guys.

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

On apache I enabled it successfully like this:

a2enmod http2
	<IfModule http2_module>
	  Protocols h2 h2c http/1.1
	  H2Direct on
a2enconf http2
service apache2 restart

Here some more about the module and it’s options:

1 Like

Great! Thanks a lot for your quick reply!

For me it does not help at all, needs to follow this procedure and enable php-fpm:

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:

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.

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:


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.


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 <> 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).