【问题标题】:Can't turn FastCGI output buffering off无法关闭 FastCGI 输出缓冲
【发布时间】:2013-02-17 19:56:17
【问题描述】:

此脚本在 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);
}

我安装了 IIS 和 FastCGI。在 PHP.ini 中,我有

zlib.output_compression = Off
output_buffering = off

C:\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"/>

似乎都没有效果。

我需要找到在 FastCGI 中关闭输出缓冲的正确方法

提前致谢

【问题讨论】:

    标签: php fastcgi


    【解决方案1】:

    我也遇到了同样的问题,也在运行 FastCGI PHP,并通过在我的索引文件(包括所有其他文件的位置)中放入以下行来修复它:

    while (@ob_end_flush());
    

    我在PHP docummentation 中找到了这个命令。 .

    【讨论】:

      【解决方案2】:

      不了解 IIS,但在 CentOS 中我必须将以下内容添加到 /etc/httpd/conf.d/fcgid.conf:

      OutputBufferSize 0
      

      搜索了一个小时在这里找到了答案:http://forum.odin.com/threads/mod_fcgid-php-flush-function.91876/

      【讨论】:

        【解决方案3】:

        解决办法在这里:PHP flush - User Contributed Notes

        对于使用 IIS 的 Windows 系统,responseBufferLimit 需要 优先于 PHP 的 output_buffering 设置。所以你还必须设置 responseBufferLimit 低于其默认值。

        简而言之,对于 IIS7+,编辑 %windir%\System32\inetsrv\config\applicationHost.config 文件并将 responseBufferLimit="0" 添加到 PHP_via_FastCGI 处理程序。

        所以整行看起来像:

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

        之后,ob_flush()flush() 将开始按预期工作。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-01-15
          • 2021-02-22
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多