index.php file not found or unable to stat - SOLVED

It seems that average Windows 7 user doesn’t like to change default system settings and as result I just spent some time helping the friend of mine to resolve the 404 error

[Fri Sep 15 20:48:34 2011] [error] [client 127.0.0.1]
script 'C:/Apache/Apache2.2/htdocs/index.php' not found or unable to stat

The friend is an absolute PHP beginner with some programing experience, who recently bought on of the recommendedWordPress book for beginners book and despite my recommendation to use all-in-one Apache distribution like XAMPP or WAMP containing MySQL, PHP and Perl, decided to start learning WordPress by by installing Apache, PHP and MySQL individually on his Windows 7 notebook.

Long story short, he successfully downloaded and installed the latest httpd-2.2.21-win32-x86-no_ssl.msi "MSI Installer Package" avoiding common mistakes like creepy Windows firewall settings and security restrictions, navigated to http://localhost/ and happily acknowledged the default Apache test page with It works! message as confirmation of the installation.

As a next step, our beginner downloaded PHP 5.3, wisely selecting VC9 thread-safe zip package from the "Windows Binaries" site and even managed to install and configure PHP 5.3 as an Apache Module.

To test PHP installation, the newbie created index.php file with the code below.
<?php
phpinfo();
>

After bouncing Apache and navigating to the page http://localhost/index.php, he got the 404 error. The previous programming experience led him to the Apache log where he found a detailed error and eventually after a few unsuccessful attempts to resolve the error by himslef called me.

[Fri Sep 15 20:48:34 2011] [error] [client 127.0.0.1]
script 'C:/Apache/Apache2.2/htdocs/index.php' not found or unable to stat

As most of you already know, the 404 or Not Found error message is a HTTP standard response code indicating that the browser was able to communicate with Apache, but the server could not find the requested page. It sounds very strange for unexperienced Windows 7 user, Apache server could see index.html file, but not able to find index.php file located in the same directory. How about we take a closer look?

file not found or unable to start


As you can see, there is a file named index.php, but default the file extensions for known file types are hidden in Windows 7 and the actual file name is index.php.txt, because the file was created as text document.

file not found or unable to stat

If you turn hiding the file extension off, you will see the real file name and the only solution to fix 404 error is to name the file properly as index.php.

Related PHP Books





4 comments:

Anonymous said...

xcelent

Anonymous said...

thanks

Anonymous said...

it was helpfull

Sandeep Arora said...

Thanks a Lot dear, I was troubled with this problem from last 2 days. I was trying a good no. of conf changes, but your simple trick helped me. Thanks once again