Page 1 of 1

How to identify Apache/PHP directive that works on XAMP

PostPosted: 26. December 2015 01:29
by TomXampp
This should be an interesting question, as I'm trying to determine what default configurations of XAMPP are allowing a certain desired behavior on my site when served on XAMPP localhost that I can't reproduce on the live server (i.e., XAMPP does it *right*, or at least as I prefer, and the live server does it *incorrectly*.)

I have a processing script that has several blocks of PHP routines in between styled content (HTML, CSS, etc.) There are messages echoed to the screen at the completion of each of the PHP functions, and it is very helpful to have them. Each routine is dependent on values established earlier, so it is ideal for everything to be in one file.

When I serve the site on localhost via XAMPP, the page is rendered in consecutive order of the elements in the script. Therefore, the heading of the page appears first, and then, importantly, progress messages are echoed to the screen as each PHP routine is completed. This works perfectly.

When I serve the site on my live server, however, the server waits until everything is processed in the script before displaying it. The configurations of the live host and XAMPP seem identical, with GZIP enabled on both, output_buffering set to 4096, etc. However, I can't determine what XAMPP is doing *right* that my live server is doing *wrong*.

I've scoured the internet to examine similar problems and solutions. One thing that looked promising was this block of code, which I inserted at the top of the script:

Code: Select all
@apache_setenv('no-gzip', 1);
@ini_set('implicit_flush', 1);
@ini_set('output_buffering', 'Off');
ob_implicit_flush(1);


With this added, XAMPP renders the page progressively (consecutively, synchronously) before it is fully processed--just as it did *without* those directives--yet the live server this time simply goes to a blank page and does not process the script at all. Perhaps this is a clue.

I'm happy to post the various configuration settings reported by PhpInfo.php on XAMPP vs those on the live server, if that would help; there's very little I've changed in the PHP.INI file in XAMPP, so I doubt it's that (and no PHP errors are reported in either case), so I suspect it's an Apache directive that is set differently on XAMPP by default than what is set on Apache at the live server.

I'm fully aware that AJAX calls can be made to accomplish this, however, if there's a way to effect what XAMPP is doing by default here (or by dint of what I may have configured specially in XAMPP), I'd prefer to go that route, as each function in the script for which I want a real-time status report is dependent on variables set by previous functions, etc., and it'd be better to leave it as one integral processing script than break it up into a sequence of AJAX calls.

I hope something I've written rings a bell with someone, or someone can offer a suggestion as to what I might try.

Many thanks!

Re: How to identify Apache/PHP directive that works on XAMP

PostPosted: 26. December 2015 14:24
by JJ_Tagy
I think the first thing I would do is a phpinfo() on both systems to see what (if any) differences.

Re: How to identify Apache/PHP directive that works on XAMP

PostPosted: 26. December 2015 17:08
by Nobbie
Did you look into the error log?

Re: How to identify Apache/PHP directive that works on XAMP

PostPosted: 26. December 2015 17:18
by TomXampp
I did compare the phpinfo of both systems and all of the obvious settings to examine were identical; also, no errors were reported in any of the log files.

My current theory is that it has to do with FastCGI being enabled on my live server. I'm going to switch it to regular CGI and try that.

http://www.fastcgi.com/archives/fastcgi-developers/2009-June/000265.html

Re: How to identify Apache/PHP directive that works on XAMP

PostPosted: 26. December 2015 17:36
by JJ_Tagy
And the PHP version is exactly the same major/minor?

Re: How to identify Apache/PHP directive that works on XAMP

PostPosted: 26. December 2015 17:40
by TomXampp
Yes. PHP 5.6. And the behavior is the same when I try it on XAMPP with PHP 7, i.e. XAMPP PHP 5.6 and PHP 7 do not buffer the script but simply output each item as it's read and interpreted, which is the desired behavior.