LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Ubuntu - LAMP > PHP path to require_once / include_once not being found (https://www.linuxquestions.org/questions/linux-software-2/ubuntu-lamp-php-path-to-require_once-include_once-not-being-found-713995/)

KeenAs 03-24-2009 03:27 AM

Ubuntu - LAMP > PHP path to require_once / include_once not being found
 
Hello LQ'ppl,


I am running "Ubuntu Server with LAMP" which is working well bu for some reason i'm having trouble with paths being found by PHP; for instance:


if(file_exists("../db/websitedb.php")) require_once("../db/websitedb.php");

returns false: file not found!

if i put in an absolute path to the server in a php file like "/var/www/db/websitedb.php" it finds the file as i would hope to in the first instance.


Is there a settings in the php.ini that i have changed or missed that will fix this? or is there a module that needs to be installed for it to work properly?

I don't have this problem with other linux servers used for web hosting for my clients, and apache/php in windows is fine also, so it seems strange that this isn't working under Ubuntu Server using LAMP.


Hoping someone can help...

TB0ne 03-25-2009 02:23 PM

Quote:

Originally Posted by KeenAs (Post 3485834)
Hello LQ'ppl,


I am running "Ubuntu Server with LAMP" which is working well bu for some reason i'm having trouble with paths being found by PHP; for instance:


if(file_exists("../db/websitedb.php")) require_once("../db/websitedb.php");

returns false: file not found!

if i put in an absolute path to the server in a php file like "/var/www/db/websitedb.php" it finds the file as i would hope to in the first instance.


Is there a settings in the php.ini that i have changed or missed that will fix this? or is there a module that needs to be installed for it to work properly?

I don't have this problem with other linux servers used for web hosting for my clients, and apache/php in windows is fine also, so it seems strange that this isn't working under Ubuntu Server using LAMP.


Hoping someone can help...

Check the permissions on the directory tree, and the entire relative path too. Be sure that you can go into the docroot where the file that's calling websitedb.php is, and type in "cd ../db" successfully. If you can't, that'll cause this. Also, is that directory a symbolic link? If so, you've got to have Apache set up to follow symlinks, otherwise it will fail.

There's nothing you need to change in php.ini...you've either got a permissions, symlink, or path problem.

KeenAs 03-26-2009 09:08 AM

Thanks for the reply TB0ne,

Permssions on all directorys under and including 'www' are 755 drwxr-xr-x

directory tree looks like:

www
---db
---public_html
--------------anywebsite

I have no problems changing directorys from the calling scripts directory e.g
from anywebsite i can 'cd ../../db' to the db directory.

The 'db' directory is a physical directory


All times are GMT -5. The time now is 06:27 AM.