Nauman Bashir
Nauman Bashir

Reputation: 1752

require_once() Error in linux (apache2)

While i try to deploy the code devloped on wamp server on the dev machine on linux , i get this error: Warning: require_once(/PHP file) [function.require-once]: failed to open stream: No such file or directory in /var/www/proj/index.php on line 38

Fatal error: require_once() [function.require]: Failed opening required '/PHP file' (include_path='.:/var/www/proj:/var/www/proj/framework:') in /var/www/proj/index.php on line 38

Now the PHP file i called is in the path "/var/www/proj/framework"

Upvotes: 0

Views: 1009

Answers (5)

Gustavo Marquez
Gustavo Marquez

Reputation: 499

This work for me, using the magic const of PHP

require once __DIR__ . "/directory/name_file.php";

Upvotes: 0

Shreyas
Shreyas

Reputation: 257


I have also faced the same problem earlier.
I found on my program that, all path was included using "\" on Windows system and linux supports "/" path separator.
Please check once that all you include path is having "/" path separator.

Upvotes: -1

Rick van Bodegraven
Rick van Bodegraven

Reputation: 179

Also, to necromance this thread even further, don't forget Windows doesn't care about case-sensitivity, and Unix/Linux does!

Upvotes: 0

Mark Baker
Mark Baker

Reputation: 212412

require_once("/PHP file")

is using an absolute path and looking for PHP file in the server's filesystem root directory

require_once("./PHP file")

or

require_once("PHP file")

is a relative path that would search for PHP file using the include path

Upvotes: 1

Your Common Sense
Your Common Sense

Reputation: 157896

You have just supplied wrong filename.
Use proper path to this PHP file

Upvotes: 1

Related Questions