[FASTCGI] Need to disable buffering

Matt hww at wilber.pointclark.net
Thu Jul 16 18:31:20 EDT 2009


First make sure that your PHP program is actually outputting information as its running rather than after it has finished so test it first outside of FastCGI. You might need to make some changes to your PHP program first. I recently had the same problem. There are many solutions, one being ob_implicit_flush() see this url for more information:
http://www.andrewdavidson.com/articles/flush-after-print/

Another solution is how(which function call) you use to execute the program in the first place. Another solution was passthru():
http://us3.php.net/manual/en/function.passthru.php

I recall some other solution was using a while loop to check to see if the program was still running and if so read from the buffer
and then output however this solution relied on php5 but I was still using php4.

The solution that was right for me in the end was this one:
        $command = "some command";

        system("mkfifo pipeout > /dev/null 2>&1");
        $pipe = popen("$command > pipeout","w");
        $pipeout = fopen("pipeout", "r");
        while (!feof($pipeout))
        {
        $tempc = fgetc($pipeout);
                if($tempc == "\n")
                {
                echo "<br>";
                }
                else
                {
                echo "$tempc";
                }
        }


Google is your friend :)


Once your PHP program is working correctly then make sure you add the -flush to the FastCGI config, refer to the manual:
http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiServer
http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiConfig
http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiExternalServer

Regards,
Matt

  "TSA Dave" <dave at shareadvantage.co.za> wrote in message news:005601c9f173$9184eab0$8c01a8c0 at TSASVR4...
  Greetings

  Can anyone please advise how I can disable the buffering in fastCGI.

  We have a Linux server running a Debian OS.
  fastCGI is installed as well as php4. 
  Previous we were using normal CGI php4. 
  The php command 'flush()' that was outputting data during the php process ( normal CGI ) is now not outputting on fastCGI -- it is buffering all the data until the php process is completed, and then outputting to the browser. 
  How can we set the fastCGI to flush the output to the browser as it is receiving the flushed data from the php process ?

  As I am a novice, could you plese tell me exactly what to add / change and in which file on the Linux server ?

  Any help would be greatly appreciated.
  Regards, Dave


------------------------------------------------------------------------------


  _______________________________________________
  FastCGI-developers mailing list
  FastCGI-developers at mailman.fastcgi.com
  http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.pins.net/mailman/private.cgi/fastcgi-developers/attachments/20090717/b2ffc43f/attachment-0001.html>


More information about the FastCGI-developers mailing list