tags:

views:

50

answers:

1

I am trying to set open_basedir in php.ini globally to /tmp/ so that I need not remember to set it in each Apache Virtual Host directive.

The second I set it in php.ini, all scripts fail to work, as only /tmp/ is allowed to be read. Is this not possible? The docs are not entirely clear, but it appears that it should work.

+1  A: 

open_basedir will affect your ability to include() or require() as well as fopen(). If you want to still be able to access the code in the virtual users home directory, you need to add additional paths to the configuration parameter:

php_admin_value open_basedir /tmp/:/home/user

This article has some good information on open_basedir. Personally - I see it as an thing to avoid, if a user has access to view files you don't want them to, there are better ways to limit access. The fact that PHP has deprecated safe mode in 5.3, and is removing it in PHP 6 makes me a little happier inside.

gnarf
just as a sidenote : open_basedir is not related to safe_mode, and only the second one will be removed in PHP 6 : open_basedir, which is considered as an efficient security mecanism, will remain.
Pascal MARTIN
Keep in mind, on OS X it is /private/var/tmp/ as /tmp/ will not work, and these are not real paths, so you want a trailing slash. php.ini would best be set to /path/to/www-docs/ which will be your global limit to keep people out of system files, then drill it down in your apache configs.