0

I installed Ubuntu 17.04 on my PC, setup Apache with PHP 7 to work on some developments, but when I tried to setup HTTP2 on my Apache, it would not work because it's not setup for Apache running mpm-prefork and I cannot disable mpm-prefork because it's used by PHP 7, any ideas how can I get this working?

Thanks.

2

The prefork model imposes quite a few restrictions on HTTP even without HTTP/2, but with HTTP/2, it prevents many features of HTTP/2 being used. Since each request occurs in a separate process and there is no multi-threading, Apache isn't able to multiplex them (serve multiple requests on the same TCP connection) unless it changed the way prefork works quite substantially, which it has chosen not to. So HTTP/2 support is limited to a single request at a time per connection when using prefork.

(This is documented here)

A good modern way of integrating PHP with a web server is to use PHP-FPM (PHP's built-in FastCGI process manager) and having the web server relay PHP requests off to that, and receive their responses. Then you can use a multithreaded web server like Apache with the worker MPM, or an event-based web server like Apache with the event MPM, or nginx (which is particularly good at HTTP/2, due to its ability to hold open thousands of connections with very little memory). In fact this is probably the most common way of using PHP with nginx, and I've also seen it used on Apache2 before for security reasons (eg having different PHP apps running as separate users). Supporting HTTP/2 seems like a decent reason too.

There are many guides to setting up web servers and PHP to use PHP-FPM.

  • That's exactly what I want to avoid (running PHP as CGI), I don't trust CGI. – jfha73 Oct 16 '17 at 15:17
  • Well this is FastCGI, and with PHP's FastCGI Process Manager it's all pretty solid. Perhaps you could put your reasons for wanting to avoid FastCGI in the question? I don't think HTTP/2 with prefork is going to ever be viable, I think Apache's resolved not to do that, because there are other ways. – thomasrutter Oct 16 '17 at 21:32
  • My reasons for not trusting CHI are mostly security, I rather have a Thread Safe PHP than a Non Thread Safe, disregarding how fast it can perform as a CGI. – jfha73 Oct 17 '17 at 14:59
  • PHP is not thread safe, not without avoiding/disabling large parts of it. That's why you can't run it inside a multithreaded server and it's why people use Apache prefork when running it inside Apache, or they use FastCGI. I suggest you look into FastCGI more, as it seems to be the obvious practical way to do what you want, and you seem to have some misconceptions about it. – thomasrutter Oct 18 '17 at 22:34
  • Well, I have been working with PHP since version 3 and I helped with PHP7 Apache SAPI when PHP7 was still as master in github, it also worked just fine on Ubuntu 16.04 without having to switch it to run as a CGI, so I don't think I have a misconception. – jfha73 Oct 19 '17 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.