Php Open_Basedir configuration Apache 2

apache-2.2PHP

We have the following setup:

  • /var/www/public <– DocumentRoot
  • /var/www/functions <– php Functions
  • /var/www/config <– php configurations

Via apache vhost configuration we open the basedir:

php_admin_value open_basedir "/var/www/functions/:/var/www/config/"

Now if I include a document under functions or config from public, that works as expected.
But if I include a config from within functions that does not.

so:

/var/www/public/index.php can include ../functions/test.php

but

/var/www/functions/test.php can't include ../config/config.php

open_basedir restriction in effect. File(../config/config.php) is not
within the allowed path(s): (/var/www/functions/:/var/www/config/) in
/var/www/functions/test.php on line 1067

Any thoughts on this maybe?

Thanks and kind regards

Linus

Additional Info:

If I include with full path it works, as in include_once("/var/www/config/config.php"); instead of include_once("../config/config.php");

Best Answer

It's something you're writing yourself? Typical PHP use in that case would be:

require_once(dirname(__FILE__) . "/bla/foo.php");

or

require_once(dirname(__FILE__) . "/../config/config.php");