How to disable the 8KB buffer in Apache/PHP-FPM on WHM?
I migrated to a new server and I've enabled PHP-FPM. On the old server, we used to use suphp and we could flush() a byte in PHP whenever we wanted. On the new server with PHP-FPM, I found out yesterday that some PHP scripts flushing just a byte or two at a time seemed to be broken. After investigating, I found out that they are not broken, but that the default configuration that comes with EA4 PHP 8.2 under PHP-FPM is to buffer at least 8KB of DATA before flushing to the browser. This is unacceptable for applications where only a handful of or even a single byte is flushed periodically. Think of a progress monitor, you know with the "." piling up while a background process is working. With how PHP-FPM is right now, it would take 8000 seconds for 8000 dots to finally be flushed to the browser all at once instead of 1 dot per second!
I dug around on the internet and aside from the obviously overkill solution of always flushing at least 8KB of DATA every single time, I found that apparently, it could probably work if I disabled buffering with this Apache directive, but I don't know where to set it not to break WHM or have WHM undo my changes at some point in the future.
FcgidOutputBufferSize 0
Any idea where I could put this and/or other genius ideas on how to completely disable the 8KB buffer in PHP-FPM on WHM? I'm using Apache 2.4.58 which comes with WHM 116.0.9.
-
Hello,
You can simply login to WHM > MultiPHP INI editor > Select the PHP version > Go to Editor mode > turn off the OutPutBuffering.
-1 -
Unfortunately, that's already what it's set to and this has no effect for PHP-FPM. It only has an effect for suphp which is the PHP handler I have to use for those domains where I need output buffering turned off. I'm specifically asking for turning off output buffering for PHP-FPM.
0 -
After a few days of searching for solutions on the internet and reading all sorts of outdated, contradictory and over all vague and non conclusive threads on various forums, including Jeff Geerling's post on the topic, then not having a single mod_proxy_fcgi related answer on here after a day, I came to the conclusion that it simply cannot be done with that Apache mod, at least not without a doctorate in computer science lol.
That's a shame, but then I realized that there was a not so cumbersome solution I could implement in just a couple minutes and that it would not even require any sort of Apache configuration at all! I'll share it here for future visitors:
1) Just add a subdomain that points to the same public_html directory in cPanel
2) Disable PHP-FPM on that subdomain in WHM.
3) There's no step 3!!!
It's gonna run using suphp just like it did for a decade on the old server... and we're back to fully functional PHP scripts with no output buffer for scripts called via that subdomain. Problem solved! New technology is just so bizarre sometimes. It's like nothing is thought through like it was in the past, but thank god that old technology is still supported (suphp).
Hope it helps somebody else lose less hair than I did.
EDIT: I thought for a second that it did not work, but it works :) It's truly hybrid depending on which subdomain I'm requesting the web page from. Just PERFECT.
1 -
Hello,
You can simply login to WHM > MultiPHP INI editor > Select the PHP version > Go to Editor mode > turn off the OutPutBuffering.
-1
Please sign in to leave a comment.
Comments
4 comments