Getting PHP to work under IIS

I’ve spent almost half a night getting PHP to install on my Windows 2003 Server under IIS. Granted: towards the end I was simply too tired to recognize that I DID change a crucial setting (cgi.force_redirect = 0), but forgot to uncomment the line …

Well, in the end it worked, but I was a little surprised to see that ISAPI support for PHP is quite limited; at least I could not – tired as I was – figure out how to make the dl() function work in an ISAPI configured IIS server. Since the basic installation script for my application (MediaWiki) really wanted to load extensions (MySQL for that matter), I was ultimately convinced that I had to walk the CGI way…

Now THAT is also quite interesting, since other than the ISAPI filter, the CGI implementation of PHP refused to cooperate. In the end, there were three steeting that made it work (and pretty smoothly, so far):

  1. Set the cgi.force_redirect = 0. Be smart and DO NOT forget to uncomment it.
  2. Set the  cgi.rfc2616_headers = 1 
  3. If you still experience problems with the CGI Application e.g. by getting an error like 
     The specified CGI application misbehaved by not
    returning a complete set of HTTP headers.

    try to increase the CGI timeout setting in the IIS Metabase (using the Metabase Explorer from the IIS resource kit). You can fint it under LM\W3SVC, the default is 300 msec, I was quite successful with 1000 msec.

Tags: PHP, IIS, Windows, ISAPI, CGI

Leave a Reply

Your email address will not be published. Required fields are marked *