Senin, 07 Februari 2011

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

Question
I 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 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. Can anyone help?

Answer
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). Questions? Given this situation you have at least the following two solutions:

Solution #1: Use an older version of PHP like 5.2I 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:

LoadModule php5_module "c:/wamp/bin/php/php5.3.0/php5apache2_2.dll"
And you may have to do 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 pull many changes once you install WAMP, which goes against the purpose of using WAMP.

Solution #2: Use correct DocumentRootIn 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. 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!

0 komentar:

 
support by: infomediaku.com