2

I have a new install of CentOS 8 Stream with Apache and PHP-FPM setup using all defaults (this defaults to PHP 7.2.24 FPM/FastCGI).

My application uses Server Sent events using JavaScripts EventSource object. To have that working I need the Apache/FPM setup to be able to send data to the client when it is available (or at least when PHP's flush call is made).

However, FPM does not do that. It will only output all data as soon as the script has finished. (Which is not what I want ...)

How can I configure PHP-FPM on Centos8 so that it can flush data during processing of the script?

I tried adding a Proxy directive in /etc/httpd/conf.d/php.conf:

<Proxy "fcgi://localhost" enablereuse=on flushpackets=on max=10>
</Proxy>

right after </FilesMatch>, but that didn't seem to work.

Bart Friederichs
  • 1,876
  • 6
  • 25
  • 43

1 Answers1

0

This is not an answer to the question, but a (temporary) work-around: disable PHP-FPM and switch back to mod_php.

In CentOS 8, this is fairly simple, in /etc/httpd/conf.modules.d/00-mpm.conf, uncomment this line:

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

and comment out the line for mpm_event.

Then add this to httpd.conf:

<IfModule prefork.c>
        StartServers              5
        MinSpareServers           5
        MaxSpareServers           10
        MaxRequestWorkers         150
        MaxConnectionsPerChild    0
</IfModule>

Source: https://www.linode.com/docs/guides/how-to-install-apache-web-server-centos-8/

Bart Friederichs
  • 1,876
  • 6
  • 25
  • 43