I have loaded PHP for use with PWS/IIS (correctly, I thought). However, when I attempt the simplest of Hello World examples (or any php code), I get the following:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

And nothing else. The source for the page returned shows the following after the colon at the end of the message:

<p><p><pre></pre>

So my script is not returning anything. Any ideas as to why?

    First thing to do, test your CGI by hand on the command line :

    php.exe c:\path\test.php

    If it works Ok, it's your PWS/IIS CGI configuration which is incorrect.

      Thanks, Olivier. In the meantime, I had tried just that, and it does seem to produce very valid HTML. Now, I just need to figure out what to tweak on the CGI side.

        4 months later

        I had this error just start spuratically today for no reason I can tell..

        anyone have any experience with it coming and going? sometimes the page works, sometimes not..

          19 days later

          Make sure that your winnt\system32 directory allows read/execute (RX) access to the PHP process.

          From Windows Explorer, right-click the c:\winnt\system32 directory, select Properties, click the Security tab, click the Permissions button, click Add, select your local machine name from the List Names From drop-down, click Show Users, select the IUSR_yourmachinename id, select Read for the Type of Access, click Add, click OK twice.

          You don't need to select "Replace permissions on subdirectories".

            2 months later

            Dave's reply doesn't appear to match up with Win2000 options. Any suggestions to this problem with W2K?

              8 days later

              Check your doc_root setting in your php.ini file. I had that set to a different directory and it caused this error. After setting it to blank, it worked fine.

                a month later

                I had the same problem running win 200 server.

                i solved the problem by adding a PHP app mapping under:

                Computer Management> Internet Information Services> edit Master Properties> Home Directory> Configuration> Add.

                this sorted me out nicely..

                  a month later

                  I was having the same problem on W2K and found out that I had just been typing the URL wrong. Duh. 🙂 I found that out by going into IIS Manager -> Properties -> Edit Master Properties -> Home Directory -> Application Settings Configuration -> Scroll down to the .php extension -> Edit and check the "Check that file exists" box. OK your way out and try to reload the page. If the server says it can't find the file then you've typed the URL wrong like I did. The weird thing is that even though I was typing the URL completely wrong, it still brought up that CGI error page. After I got it working I went back and cleaned up some permissions I had set to try to get it to work. The ONLY permissions it needs to work are Read/Write access to the uploadtmp and session directories where PHP was installed and Execute permission on the php.exe and php4ts.dll for the IUSR_MachineName account just like the installation says at the end in that little pop-up box. Hope this helps!!!

                    3 months later

                    For what it's worth, I've been battling with this for ages - trying just about everything I can find on the web, to no avail. However, I just tried pointing my browser at the test PHP file (previously I'd been trying a test file in my normal virtual directory)installed in c:\Inetpubs\scripts\php (i.e. http://localhost/scripts/php/test.php) and bingo, it worked!

                    Spurred on by this victory, I created a new virtual directory on my C: drive and copied the test file there. Again it worked.

                    However, I still can't get it working in a virtual directory that is a share, rather than local drive - my guess is that PHP/IIS isn't going to work with files located on a remote shared drive.

                    For what it's worth, I used the PHP 4.0.4 EasyWindows installer. I've read a lot of stuff about setting the file type for .php to <path>\php.exe %s %s - my working setup doesn't have the %s %s. Also, there's a lot of stuff written about permissions which doesn't apply if you're using Win2K on a FAT32 partition.

                      Aha - I just downloaded the PHP4.1.0 zip and installer - unzipped into C:\inetpub\scripts\php and then ran the installer - PHP now works fine from shares too. What a happy ending!

                        Write a Reply...