• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Including files outside httpdocs folder fails

B

bmatzner

Guest
Hi,

I have a PHP application sitting in my httpdocs folder

/domain/httpdocs/index.php

using a require_once pointing to a file outside this folder

/domain/library/Zend/Controller/Front.php

The file is there and is set to 644

I get this error message though.

Code:
[Mon Oct 29 12:22:04 2007] [error] [client xxx] PHP Warning:  require_once(Zend/Controller/Front.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /var/www/vhosts/domain/httpdocs/index.php on line 51
Code:
[Mon Oct 29 12:22:04 2007] [error] [client xxx] PHP Fatal error:  require_once() [<a href='function.require'>function.require</a>]: Failed opening required 'Zend/Controller/Front.php' (include_path='.:/var/www/vhosts/domain/library:/var/www/vhosts/domain/application/models:/usr/share/php:/usr/share/pear') in /var/www/vhosts/domain/httpdocs/index.php on line 51

I checked permissions, even changed owner and group IDs so to make sure it nothing to do with it.

I tried adding a vhost.conf file and adding the /var/www/vhosts/domain folder to open_basedir

Still I get these error messages.

On other servers, this application works just fine.

Any hints?

Thanks,
Bernd
 
If I am not wrong, if there were permissions or open_basedir problem, then you would see appropriate PHP errors about them... However 'no such file' error means exactly what it means - file cannot be found in specified path(s), try to check what path is used in the script, try to use full path instead of relative and so on..
 
Hi Dirty,

the file is definitely there... It's strange, because everything's working properly on my local Apache. It's also working on a Windows IIS, it's just here on this Debian machine with Plesk it doesn't work. It really has to do with the include_path...

Still wondering,
Bernd
 
Try specifying full path to the file: require_once(/domain/library/Zend/Controller/Front.php) instead of the relative path require_once(Zend/Controller/Front.php).

./anb
 
After much fiddling, I could resolve it by adding a vhost.conf file for the domain and meticulously adding all the necessary folders outside my root to the open basedir list:

<Directory /var/www/vhosts/domain/httpdocs>
<IfModule mod_php4.c>
php_admin_flag engine on
php_admin_flag safe_mode on
php_admin_value open_basedir "/tmp:/var/www/vhosts/domain:/var/www/vhosts/domain/httpdocs:/var/www/vhosts/domain/library"
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode on
php_admin_value open_basedir "/tmp:/var/www/vhosts/domain:/var/www/vhosts/domain/httpdocs:/var/www/vhosts/domain/library"
</IfModule>
Options +Includes -ExecCGI
</Directory>

Then reload Apache and I was up and running.

Bernd
 
Back
Top