Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

i have nas storage attached in load balance servers that running cpanel - php - mysql ... etc

when php tries to read (incloded file) such as :

require_once "config.main.php";

it couldn't be loaded with error :

PHP Warning: require_once(config.main.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory

and when i open that included file from servers command-line with editor such as nano and try to run the same file again it works perfectly

so , the question is : why php can't see that file directly ? why do i need to open the file manually from commaind-line so php can see it ?

share|improve this question

2 Answers 2

Check that the user that the webserver runs as has permission to read the file, so the directories need to have an r-x permission that allows the user to traverse them and the .php file itself requires (a minimum) r-- so the user can read it.

Is the file in the same directory as the file that contains the require ? If not make sure that the directory containing the required file is in include_path or provide a full path e.g.

share|improve this answer
it has the right permissions for sure , the files works perfectly with php after manual open with editor , 1st : php index.php > failed , 2nd : nano index.php & exit > work , 3rd : php index.php > work –  Eslam Elyamany Jul 25 '12 at 15:47

You didnt copy the whole error line so not sure which is the error, but php require function (as include function) just includes the content of the file. If its not a permissions issue, probably there is a connection error with the Nas and gets online again when you open the file with the editor.

Have in mind that php procesor is running as a module in the apache server, and depending on module, ita running under apaches or web site owner user

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.