No Input File Specified Error When Running PHP Script With IIS

Date Initially Written: 11 November 2006.

Problem: When running a PHP script with IIS a No input file specified error is shown.

Operating System: Windows 2000 Professional with service pack 4.

Background: A website I was making that uses PHP would only show No input file specified whenever I tried to open a PHP page in my browser. This problem only occurred with one website, all other websites that used PHP functioned properly.

Resolution Steps: I first looked in the IIS management console (Start Settings Control Panel Administrative Tools Internet Services Manager) and compared the settings for the troublesome site with a known good site. All of the settings were identical.

Some research then lead me to look at the php.ini file and in particular the doc_root setting. I had the following setting:

doc_root = "d:\Inetpub\wwwroot"

The comments above this setting say:

; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues. The alternate is to use the
; cgi.force_redirect configuration below

I'm using PHP in ISAPI mode on my development workstation, not CGI, so I tried commenting out the setting so it looked like this:

; doc_root = "d:\Inetpub\wwwroot"

and then I restarted IIS by opening a command prompt (Start Programs Accessories Command Prompt) and type the command: iisreset

This fixed the problem!

Recommended Reading For PHP Programmers: Programming PHP