3

i will have numerous subdirectories eg. /home/a, /home/a/file, /home/a/txt, /home/b, /home/b/file, /home/b/txt, etc.

the subdirectories are created on demand. i need to add all subdirectories to open_basedir.

pls advise how to make open_basedir recognise all subdirectories of a top path?

peter chan
  • 31
  • 1
  • 2
  • 1
    It already does. It's the **base dir** -ectory, meaning the root of an entire directory tree. If `/home/` is your open_basedir, then `/home/a`, `/home/b`, etc. are already part of that directory tree. So what is your question? – Dan Grossman Feb 19 '11 at 03:39

3 Answers3

5

From http://php.net/manual/en/ini.core.php#ini.open-basedir

The restriction specified with open_basedir is a directory name since PHP 5.2.16 and 5.3.4. Previous versions used it as a prefix. This means that "open_basedir = /dir/incl" also allowed access to "/dir/include" and "/dir/incls" if they exist. When you want to restrict access to only the specified directory, end with a slash. For example: open_basedir = /dir/incl/

/dir/incl/ = only the directory no subdirectories

dir/incl = all subdirectories

Community
  • 1
  • 1
VPDD
  • 131
  • 4
  • 7
1

If Apache doesn't find some directory within specified path -- upgrading of some php module may fix the problem. I have such problem when used PHP 5.3.15 and eAccelerator which has been installed when I used PHP 5.3.3.

PHP with eAccelerator was unable to include all subdirectories within specified open_basedir, until I upgraded eAccelerator to appropriate version of PHP.

  • The most important for me is to flush the eAccelerator cache. `rm -rf /var/cache/php-eaccelerator/*` after changing `open_basedir`, otherwise otherwise it reports obsoleted warnings. – hynekcer Jan 28 '13 at 02:17
-1

open_basedir means all subdirectories are available, once the basedir is on your include_path. You will of course need to make sure any paths to included files are correct, e.g. If you want something in /home/b/file you'll need to

include('b/file/myfile.php');
David Gillen
  • 1,172
  • 5
  • 14