Why does any .php page give me a 404 error on Server 2008 with IIS 7.0? [closed]
Solution 1:
Just wanted to add the stupid answer encase anyone else find this issue with the same problem. "A mate" created the test file on the server. He was getting the 404 error. What had happened, was that windows was hiding file extensions, so the file was actually called index.php.txt... Not a funny 30 minutes.
Solution 2:
When I was getting this error message I noticed that I didn't even have php-cgi.exe
file in the C:\Program Files\PHP
directory.
The other helpful method I found was that if you are getting FastCGI errors, to try double clicking directly on the php-cgi.exe
file and then look in the Windows Application logs for errors if it crashes. I got this from this comment from a PHP Bug report:
[2010-04-22 06:43 UTC] sejo at iteontech dot com
After debugging IIS and a bunch of other crazy things, this is what worked for me. I have PHP 5.3.2 on Windows 7 and IIS 7. Try to execute PHP-CGI.EXE (BY DOUBLECLICKING ON IT). See if you get any error messages/ pop-ups. I got a ton of them and it all boiled down on having a bunch of extensions turned on, but not being available in my ext folder. Clear the PHP.INI of those invalid extensions and the problem should go away.
Solution 3:
Well, I'm not sure what I did, but somehow I fixed it. I removed the website and re-added it, then checked my FastCGI Mapping settings, everything looked just like before, but this time it works. I'd still like to know why I was getting the error if possible.
Solution 4:
By default IIS will not serve any file for which it does not have a valid MIME Type mapping and will 404 the response
If the .php extension does not have a MIME type defined for it for the website that you're trying to run PHP then IIS will not serve the file even if there is a relevant handler for that file type.
Just checked the IIS 7 Manager on my server and there is no mapping for PHP by default in the MIME Types list, I suspect that if your website existed before you installed FastCGI it does not automatically add the mapping to existing websites whereas when you created the new website FastCGI was already installed.
I could of course be completely wrong about that last bit but the File extension to MIME Type mapping issue is a security feature of IIS - no mapping = no files served with that extension
Solution 5:
My solution to this error had two parts:
- (from @icc97's answer) -- double-click on php-cgi.exe in your PHP folder to make sure it can start up ok.
- Turns out that my
index.php
file was really namedindex.php.htm
(turn off "hide file extension names")