Output buffering in PHP in IIS 8.5RSS

8 replies

Last post Jan 25, 2018 04:18 PM by bmcn99

  • Output buffering in PHP in IIS 8.5

    Jan 03, 2018 01:57 PM|bmcn99|LINK

    We would like to output progress updates during a long process in PHP but everything we've tried so far for output buffering does not seem to work with IIS 8.5.

    We've tried the suggestions outlines in this thread: https://stackoverflow.com/questions/7178514/php-flush-stopped-flushing-in-iis7-5 and this thread: https://stackoverflow.com/questions/37315815/php-flush-stopped-flushing-in-iis-8 without success. We've found a few other settings that were supposed to fix the problem but didn't specify what IIS version they belong to and haven't found them in 8.5.

    Additionally some of the information in those stackoverflow posts targeted information in the config file, but our config here is extremely barebones so those lines of information don't exist.

    Can anyone specify exactly what settings need to be set for this to work in 8,5? Or what lines need to be added (Not modified) in the config file? 

    Any help would be much appreciated, thanks.

  • Re: Output buffering in PHP in IIS 8.5

    Jan 04, 2018 03:09 AM|Yuk Ding|LINK

    Hi bmcn99,

    You mean the command line not working or the configuration can't modify the output buffer?

    You could try this command and it works fine on my side

    >cd c:\windows\system32\inetsrv\
    
    appcmd.exe set config  -section:system.webServer/handlers /[name='PHP_via_FastCGI1'].responseBufferLimit:"0"  /commit:apphost
    

    In addition, you could try the different web browser to check if only one browser not work or all the web browser not work.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: Output buffering in PHP in IIS 8.5

    Jan 05, 2018 03:51 PM|bmcn99|LINK

    Hi Yuk, I believe that command alters that section of the config file but I have attached the entirety of our config file below and there is no section to alter so it does nothing for us.

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <security>
                <requestFiltering>
                    <requestLimits maxAllowedContentLength="3000000000" maxUrl="4096000000" maxQueryString="2048000000" />
                </requestFiltering>
            </security>
        </system.webServer>
    </configuration>
  • Re: Output buffering in PHP in IIS 8.5

    Jan 09, 2018 08:56 AM|Yuk Ding|LINK

    Hi bmcn99,

    Does PHP itself have some restriction like this? Because I could only find these configuration which are related to your requirement in IIS.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: Output buffering in PHP in IIS 8.5

    Jan 09, 2018 01:54 PM|bmcn99|LINK

    PHP has it's own config file and there are some parameters that govern output buffering, but we have set them to output immediately, and it works as intended on my local apache setup.

    I did a test where I output ~2MB of text while processing and IIS does update the screen at some point before it finishes, so there should be a setting that governs what that value is. I would assume that if it is not set in the IIS config file that it is still accessible elsewhere, is this not the case?

    Also would it be possible for you to share your config file? Ours is in use on a live server so I would not like to start fiddling with it and guessing the proper format for setting that value.

  • Re: Output buffering in PHP in IIS 8.5

    Jan 15, 2018 09:10 AM|Yuk Ding|LINK

    Hi  bmcn99,

    I just find the parameter responseBufferLimit="0" . You could add it to the end of your  PHP_via_FASTCGI handler section like this in applicationhost.config:

    <handlers accessPolicy="Read, Script"> <add name="PHP_via_FastCGI1" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v7.1\php-cgi.exe" resourceType="Either" responseBufferLimit="0" />
    

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: Output buffering in PHP in IIS 8.5

    Jan 18, 2018 12:02 AM|bmcn99|LINK

    Hi Yuk, I cannot add it to the end of my PHP_via_FASTCGI handler as it does not exist. I posted my config file in its entirety up above, if I were to insert that line into it I am unsure which section it would be placed into. Based on what I've read on this page: https://docs.microsoft.com/en-us/iis/configuration/system.webserver/ I believe it should be placed alongside the security node as a child under system.webServer which would make it look like the following below, is that correct?

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <security>
                <requestFiltering>
                    <requestLimits maxAllowedContentLength="3000000000" maxUrl="4096000000" maxQueryString="2048000000" />
                </requestFiltering>
            </security>
    <handlers accessPolicy="Read, Script"> <add name="PHP_via_FastCGI1" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v7.1\php-cgi.exe" resourceType="Either" responseBufferLimit="0" /> </system.webServer> </configuration>

  • Re: Output buffering in PHP in IIS 8.5

    Jan 18, 2018 07:26 AM|Yuk Ding|LINK

    HI bmcn99,

    I mean if you need to use PHP in IIS 8.5, then you should have a handler which is mapped to php-cgi.exe. Then you only need to add a responseBufferLimit="0" to the end of that line.

    https://stackoverflow.com/questions/7178514/php-flush-stopped-flushing-in-iis7-5

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: Output buffering in PHP in IIS 8.5

    Jan 25, 2018 04:18 PM|bmcn99|LINK

    Hi Yuk, I was able to get a VirtualBox windows server 2012 to test this on, can you outline the steps to reach that handler? I haven't been able to find it.