简体   繁体   English

无法关闭 FastCGI 输出缓冲

[英]Can't turn FastCGI output buffering off

This script outputs after 10 seconds instead of incrementally:此脚本在 10 秒后输出而不是增量输出:

ob_start(); // Start output buffer (if not enabled in php.ini)
for ($i = 0; $i < 10; $i++) {
    echo $i, ' ';
    ob_flush();
    flush();
    sleep(1);
}

I have IIS and FastCGI installed.我安装了 IIS 和 FastCGI。 in PHP.ini, I have在 PHP.ini 中,我有

zlib.output_compression = Off
output_buffering = off

In C:\\Windows\\System32\\inetsrv\\Config\\applicationHost.config I haveC:\\Windows\\System32\\inetsrv\\Config\\applicationHost.config我有

<add name="PHP_viaFastCGI" 
path="*.php" 
verb="*" 
modules="FastCgiModule" 
scriptProcessor="C:\php\php-cgi.exe" 
resourceType="Unspecified" 
ResponseBufferLimit = "0"/>

All have seemingly no effect.一切似乎都没有效果。

I need to find the correct way to turn off output buffering in FastCGI我需要找到在 FastCGI 中关闭输出缓冲的正确方法

Thanks in advance提前致谢

I had the same issue, also running FastCGI PHP, and got it fixed by putting the following line in my index file (from where all other files are included), before everything else:我有同样的问题,也运行 FastCGI PHP,并通过在我的索引文件中(从包含所有其他文件的位置)中添加以下行来修复它,在其他一切之前:

while (@ob_end_flush());

I found this command in the PHP docummentation .我在PHP 文档中找到了这个命令。 . .

Don't know about IIS, but in CentOS I had to add the following to /etc/httpd/conf.d/fcgid.conf:不知道 IIS,但在 CentOS 中,我必须将以下内容添加到 /etc/httpd/conf.d/fcgid.conf:

OutputBufferSize 0

Found the answer here after searching for an hour: http://forum.odin.com/threads/mod_fcgid-php-flush-function.91876/搜索一个小时后在这里找到答案: http : //forum.odin.com/threads/mod_fcgid-php-flush-function.91876/

The solution is here: PHP flush - User Contributed Notes解决方案在这里: PHP flush - User Contributed Notes

For a Windows system using IIS, the responseBufferLimit takes precedence over PHP's output_buffering settings.对于使用 IIS 的 Windows 系统, responseBufferLimit优先于 PHP 的output_buffering设置。 So you must also set the responseBufferLimit to be something lower than its default value.因此,您还必须将responseBufferLimit设置为低于其默认值的值。

In short, for IIS7+, edit the %windir%\\System32\\inetsrv\\config\\applicationHost.config file and add responseBufferLimit="0" to the PHP_via_FastCGI handler.简而言之,对于 IIS7+,编辑%windir%\\System32\\inetsrv\\config\\applicationHost.config文件并将responseBufferLimit="0"添加到PHP_via_FastCGI处理程序。

So the entire line will look something like:所以整行看起来像:

<add name="PHP_via_FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\\PHP\\php-cgi.exe" resourceType="Either" responseBufferLimit="0" />

After that, ob_flush() and flush() will start to work as expected.之后, ob_flush()flush()将开始按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM