php output buffer. No output, ob_flush etc..

Questions about HTTP Access/Mods may go here
Forum rules
1) This is a user forum for Synology users to share experience/help out each other: if you need direct assistance from the Synology technical support team, please use the following form:

https://account.synology.com/support/support_form.php?lang=enu



2) To avoid putting users' DiskStation at risk, please don't paste links to any patches provided by our Support team as we will systematically remove them. Our Support team will provide the correct patch for your DiskStation model.
rgj
I'm New!
I'm New!
Posts: 5
Joined: Tue May 21, 2013 5:13 pm

php output buffer. No output, ob_flush etc..

Postby rgj » Sat Dec 06, 2014 1:35 pm

I have been unable to get my diskstation to output php 'echo' commands whilst php script is running. I have tried all sorts of variations with the ob_ commands, ob_flush etc.. commands plus changing output buffer settings on php.ini but all to no avail. If I run my script on a remote server (hosting) I get output, but not on my DS. I'm guessing it's something to do with the setup (php.ini) or some such. Any clues anyone ?
nvrsk
Beginner
Beginner
Posts: 21
Joined: Sat Mar 05, 2011 6:13 pm

Re: php output buffer. No output, ob_flush etc..

Postby nvrsk » Tue Mar 01, 2016 1:30 pm

came to the same problem today, and all that I could find here were questions without answers.
so, here is the solution that I was able to figure out:

the problem of flush(); not working comes from FastCgi (http://www.fastcgi.com/mod_fastcgi/docs ... stcgi.html) which is used by Apache and has buffering turned on by the default.
to fix this you have to login via SSH, browse to /etc/httpd/conf/extra directory and edit the FastCGI module config - mod_fastcgi.conf
locate line:

Code: Select all

FastCgiExternalServer /php-fpm-handler -socket /run/php-fpm/php-fpm.sock -idle-timeout 3600
and add " -flush" to the end of it.

then you have to restart Apache webserver:
go to "Control Panel" -> "Web Services" -> uncheck "Enable Web Station" -> "Apply", re-check "Enable Web Station" -> "Apply"
or make it via SSH command-line:

Code: Select all

/usr/syno/sbin/synoservicecfg --restart httpd-user

and here's simple flush-test.php to see the result:

Code: Select all

<?php
header( 'Content-type: text/html; charset=utf-8' );
echo '<center><font face=courier size=20>-=[START]=-<br />';
for($i=0;$i<10;$i++)
{
    echo  $i.'<br />';
    flush();
    ob_flush();
    sleep(1);
}
echo '-=[ END ]=-<br></font></center />';
?>
rgj
I'm New!
I'm New!
Posts: 5
Joined: Tue May 21, 2013 5:13 pm

Re: php output buffer. No output, ob_flush etc..

Postby rgj » Thu Apr 28, 2016 11:12 am

Thanks nvrsk

Problem is I don't seem to have a /etc/httpd/conf/ folder on my system running DSM 6.
nvrsk
Beginner
Beginner
Posts: 21
Joined: Sat Mar 05, 2011 6:13 pm

Re: php output buffer. No output, ob_flush etc..

Postby nvrsk » Fri May 13, 2016 8:51 am

after updating the system from DSM 5.2-5644 to the latest DSM 5.2-5967 have had to repeat the procedure above since the config contents was rewritten with defaults.
more to say, all of my scripts in /usr/syno/synoman/phpsrc directory (some features like Postgre access works just from that path) were completely erased without a trace, so, make sure to have a backup by the hand.

rgj:
you may try to locate the DSM6 placement of file mod_fastcgi.conf manually via SSH.
this is a result from DSM5 directory structure:

Code: Select all

> find / -name mod_fastcgi.conf

/etc/httpd/conf/extra/mod_fastcgi.conf
/etc.defaults/httpd/conf/extra/mod_fastcgi.conf
zvedavec
I'm New!
I'm New!
Posts: 1
Joined: Sun Jun 05, 2016 2:20 am

Re: php output buffer. No output, ob_flush etc..

Postby zvedavec » Sun Jun 05, 2016 12:19 pm

i have same problem. i have dsm 6 too and i found only one mod_fastcgi.conf file in:

/volume1/@appstore/WebStation/usr/local/etc/httpd/conf/extra/

is this location fine?


btw. if you use:
<?php header ('Content-Encoding: none'); ?>
then ob_flush (); flush (); working but content is refreshed after a few seconds.

edit: found another problem with dsm 6.. Control Panel -> Web Services is missing in my control panel. :(
ryan010101
I'm New!
I'm New!
Posts: 7
Joined: Tue Nov 22, 2011 10:21 pm

Re: php output buffer. No output, ob_flush etc..

Postby ryan010101 » Wed Dec 07, 2016 4:05 pm

I can confirm this works for me in DSM 6.0.2 (thanks much nvrsk!)

The file to edit is here (mine is volume2 but yours is probably volume1):
/volume2/@appstore/WebStation/usr/local/etc/httpd/conf/extra/mod_fastcgi.conf

I restarted Apache using
/usr/syno/sbin/synoservicecfg --restart pkgctl-WebStation

Return to “HTTP/Apache Mods”

Who is online

Users browsing this forum: No registered users and 1 guest