Feb 7, 2011

f Comment

Solving PHP "Failed To Open Stream: No such file or directory in Unknown on line 0" Error in MINUTES!

AmazonI am running WAMP on Windows 7 and my WAMP directory is at C:\wamp. I specify 'C:\wamp\www' to be my document root in Apache's httpd.conf. I create a symbolic link, C:\wamp\www\myWebSite, to point to a directory, D:\myWebSite, where my website content is actually located. I got the following error in the browser when trying to access any of my web pages under D:\myWebSite:

Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

Fatal error: Unknown: Failed opening required 'C:/wamp/www/index.php' (include_path='.;C:\php5\pear') in Unknown on line 0

I've looked at the logs but there's nothing helpful. Read on to find how to solve it in MINUTES!

This error occurs because the latest WAMP uses PHP 5.3 which does NOT support directory junction (soft link) or hard links in Windows (refer to How To Create A Soft Link In Windows for a tutorial on creating a soft or hard link in Windows). Given this fact you have at least the following two solutions:

Solution #1
Use an older version of PHP like 5.2. I tried version 5.2.11 and soft links work fine. This means rolling back PHP module to 5.2. You may have to edit the path of the following line in httpd.conf if you are using Apache:

LoadModule php5_module "c:/wamp/bin/php/php5.3.0/php5apache2_2.dll"
And you may have to download other related modules as well. Of course you can try to find an older WAMP that uses PHP 5.2. In my opinion this is not a good solution as you need to make many changes after you installed WAMP.

Solution #2 - BETTER
Use correct DocumentRoot. In your Apache's httpd.conf change DocumentRoot to the actual website folder which in this case is D:\myWebSite, and change other related settings accordingly. Then delete the soft link C:\wamp\www\myWebSite.

This should be a much better solution as your website content can be located anywhere in your file system!

Any questions let me know!
Please leave a comment here!
One Minute Information - by Michael Wen
ADVERTISING WITH US - Direct your advertising requests to Michael