?
Solved

CGI Application misbehaved Error using PHP 4.4.9 as a CGI

Posted on 2011-04-22
12
Medium Priority
?
859 Views
Last Modified: 2013-12-13
I am receiving the infamous "CGI Application Misbehaved" Error while using PHP as a CGI application.  We are running Windows Server 2003 with IIS 6.0.  If I go into the site properties and set PHP to use the ISAPI dll it works just beautifully.  However my Boss is dead-set on having this work as a CGI because "ISAPI is unstable" - yeah must be it's the .EXE causing all the problems.  Anyway there are about a million posts for this and everyone seems to have a "Solution" from assinging Read rights to the IUSR_xxx account (bad idea and doesn't work) to changing the CGI timeout setting in the Metabase.  None of these are working I get this error every time I try to use php.exe as a CGI.  As I mentioned above as an ISAPI it works PERFECTLY. So naturally I can't use that - it would be too easy.
0
Comment
Question by:Jeff_H8S_PHP
  • 6
  • 6
12 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 35452200
Have you looked at FastCGI?  http://www.iis.net/download/fastcgi for IIS 6.
0
 

Author Comment

by:Jeff_H8S_PHP
ID: 35460593
I'm really just trying to get the php.exe working as a CGI app - Using the FastCGI I might as well just use PHP in ISAPI mode.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 35460846
Ok, that's a little confusing.  The two primary choices for PHP basic operation thru the web server are ISAPI and FastCGI.  FastCGI seems to be prefered as of PHP 5.3 though I don't remember why except for people saying it is more stable (without any supporting info).  There is also php-cgi but I haven't seen or heard of anyone using that.

There is also the old concept of a "CGI app" (like Perl has been used) that gets elevated privileges to access part of the system outside the web server.

So the question is what or which of these things are you trying to do?
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 

Author Comment

by:Jeff_H8S_PHP
ID: 35461016
Sorry Dave - I need to clarify.

My issue is this - we have a server that renders .Pdf files for a client.  Most of the site is written in ASP .NET with a SQL backend.  Howver this app has evolved a lot since 2002 and there is a very small (but pretty important) amount of code that uses PHP. It was using 4.3.1 running in CGI mode.  In the iis config the .php extession points to php.exe to handle PHP scripts.  We had to upgrade to 4.4.x (we used 4.4.9) because our developer needed some functionality that was not in 4.3.  Switching to a 5.x release of PHP broke a lot of the code so we are staying with 4.4 since we want to phase this out anyway.

Reading your last post it would be the third option I am trying to pull off - for some reason this has always been set up as an old school CGI app.  Each request for php calls the php.exe program and it processes the request - this is what is giving me such a hard time.  When I use the ISAPI it works perfectly.  Using the CGI app causes this error. I have looked for solutions but noone seems to agree what the problem is:

http://bugs.php.net/bug.php?id=25863

So yeah - sorry about the confusion.  The ISAPI is working great for us now but my boss is insisting that I get it working as a CGI app so while I am perfectly content with it running as ISAPI - I have to get this working as a CGI app.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 35461901
In that article, they are actually describing several different problems which is why they don't agree.  In my copy of PHP 4.4.9, there are two versions of 'php.exe', one for use with the web server and one in 'C:\PHP\cli' for command line use.  Where did you get PHP 4.4.9 and what version did you get?  Yes, there was more than one version.  One installed as CGI and the other as ISAPI.   The version I have does not have the 'php4-cgi.exe' version.
0
 

Author Comment

by:Jeff_H8S_PHP
ID: 35462066
Yeah - my version does not have the pgp-cgi version.  I got it from the museum archives at php.net.  THAT sounds like it might be the issue.  If  i am reading what you are saying correctly I have a version that is meant to be used as ISAPT and the inclusion of the php.exe binary is for command-line use NOT for CGI use.  Thanks a lot that quite possibly explains a whole lot.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 35462376
There are two separate version of 'php.exe' in PHP 4.4.9.  One in 'C:\PHP' is for ISAPI and the one in 'C:\PHP\cli' for command line operation.

What error messages are you getting?
0
 

Author Comment

by:Jeff_H8S_PHP
ID: 35462711
The only error that I am receiving is the one about " CGI Application misbehaved by not returning a complete set of http headers."  I do'nt receive this when I change the .php extension to point to the isapi DLL file instead of php.exe. It runs just fine.  I do however need to get this working as a CGI not ISAPI.  Whe can I get a distribution with the php-cgi.exe ?
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 35463236
I can't find any source for "php-cgi.exe" for PHP 4.4.x on Windows.  FastCGI from Microsoft requires it also.
0
 

Author Comment

by:Jeff_H8S_PHP
ID: 35463559
I found out what my issue was. Apparently the .ini file has to be in the same directory as the php.exe binary.  It is working now.  But than you for your help.  It looks like I will be setting up a new server with PHP5 and MySQL so I'll use this new knowledge when I set that up.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 35463627
That's interesting.  I wouldn't have known that because I always keep a copy of 'php.ini' in my PHP directory.  Thanks for the points.
0
 

Author Comment

by:Jeff_H8S_PHP
ID: 35463659
Yeah really weird - because it never mattered when I ran it as an ISAPI - and it's funny too because one of the first things I checked was my PATH settings to make sure something like this wasn't happening - I just happened to read a random posting not even related to this error and that solved it.  I appreciate your help though - thanks again.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question