Reputation: 41
I'm having issue streaming output from PHP script smoothly after upgrading OS, Apache and PHP.
I have a shell script that executed by a PHP script, its take between 1 to 2 minutes to complete, the output about 20-30 lines.
The current setup: everything is working nicely, whatever the shell script printout the browser display it right away until its finish executing.
The new setup, the browser will not show any result until more lines outputted by shell script and print them all together let say each print contains 5-+ lines all together until all output printed out, while these lines printed out by shell script separately and there like 5 seconds different between each line.
I downgraded PHP on the new setup to 7.3.33 but no luck, so its unlikely a PHP issue. I also tried different browsers, also no luck, the issue remains the same.
So why the new setup is requiring more data to be printed out by the shell script in case to be delivered to the browser? where i should look to figure out what is going on?
Current system (working): OS: RHEL 7.9, Apache: 2.4.34, PHP: 7.3.33,
New setup (Broken): OS: RHEL 8.10, Apache: 2.4.37, PHP: 8.2.13
All PHP and Apache configs are the same on both setups.
The PHP code
<?php
$script = "script.sh";
while (@ob_end_flush());
$proc = popen($script, 'r');
while (!feof($proce)) {
$output = fread($proc, 8192);
echo "$output";
@flush();
}
Upvotes: 1
Views: 39