LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > PHP > Usability issue with LSAPI PHP

Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2007, 11:51 AM
jrmarino jrmarino is offline
Senior Member
 
Join Date: Apr 2007
Posts: 114
Default Usability issue with LSAPI PHP

One php site that I have just showed up with blank pages and absolute zero errors in the log. I could not figure out what was going on with it.

I have LSAPI PHP 5.2.2 compiled.

So I get to the command line, and run the file in the command line using fastcgi PHP 5.2.1. No problem, the file executed perfectly.

Then I ran the same exact file with LSAPI PHP from the command line, and it brought up a bought of "can't start headers, output already started errors" immediately.

This was caused by extra white space in the config file after the closing "?>" bracket. This annoyance plagued PHP 4, but thankfully Zend fixed that problem for PHP 5. It ignores white space between the last closing bracket and EOF if there is no other characters present there.

So I have two major worries here:

1) Why is LSAPI PHP sensitive to trailing white space when CLI/CGI PHP is not?

2) Why did Litespeed return no output and not log any errors when the script was clearing outputting errors? I've seen similar behavior with litespeed when the fastcgi process died to a 500 server error. Is that is what is going on here?
Reply With Quote
  #2  
Old 05-08-2007, 12:30 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,583
1) I think you need to turn output buffering in php.ini to avoid the "can't start headers, output already started errors". It really is the PHP internal, have thing to do with LSAPI, LSAPI just do what have been told by the PHP engine.

There is nothing to worry about response headers when running PHP from command. You can run LSAPI PHP from command line, should get the same result as the FCGI PHP.

2) Since the output header has been messed up, it would be difficult for the web server to interpret the response correctly. Due to the missing reply headers, part or whole reply body may be treated as response header, it is likely that the web page is broken in the browser.
Reply With Quote
  #3  
Old 05-08-2007, 12:42 PM
jrmarino jrmarino is offline
Senior Member
 
Join Date: Apr 2007
Posts: 114
You may have misunderstood the problem of number 1. I'm talking about the white space between the end of the script and the end of the file. for example:

Code:
<php

/* do stuff */

?>


(See this white space?  This is ignored by CLI/CGI PHP.  It is NOT ignored LSAPI PHP and it gets sent to stdout)
[EOF]
Both the fastcgi and lsapi PHP were compiled from the same source. The one thing that might explain this: fastcgi php looks at the php.ini in the default location. If lsapi does not, it could explain some of these differences.

2) I accept that litespeed may have interpreted the entire page as a header. I still don't know why an error was not logged. I'm also repeating: the output between lsapi PHP and fastcgi php running on the command line was not equal due to the differently handling of the trailing white space.


I can imagine some php.ini setting that handles trailing white space, but that means lsapi and fastcgi php are not using the same php.ini file.
Reply With Quote
  #4  
Old 05-08-2007, 12:51 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,583
Whether to ignore the trailing white space is completely inside PHP engine, LSAPI has no control over it, like you said, it might be controled by a configuration in php.ini. You have to use the same php.ini when you compare the output of FCGI PHP and LSAPI PHP. Just use command line option "-c <path_to_ini_dir>".

If the error messages were not sent to STDERR stream, then it will be interpreted as the headers as well, otherwise, errors will show up in our error.log.
Reply With Quote
  #5  
Old 05-08-2007, 01:01 PM
jrmarino jrmarino is offline
Senior Member
 
Join Date: Apr 2007
Posts: 114
I ran "php -i" for both lsapi and fastcgi versions.

That confirms that both are using the exact same ini file (/opt/csw/etc/php.ini)

Yet they are behaving differently. That's just a fact -- you can tell me that they should not be, but that's not what I'm seeing.

When there is an error, lsphp will print it with the page (as it should). However in the particular case I'm telling you about, it did not.

I've also seen other examples where the php error was logged, so it's worked before.
Reply With Quote
  #6  
Old 05-08-2007, 01:54 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,583
I could not reproduce this with a default FastCGI PHP 5.2.2 build with "./configure --enable-fastcgi", tried the php.ini-dist and php.ini-recommended come with the package.
test code: hello.php
Code:

<?php print   "hello,world"; ?>
Both leading and trialing space has not be removed when run it from command line. I am not sure what exactly will trigger FCGI PHP to ignore whitespaces. Do you have any idea? or have a working test case?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:46 PM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.