Use PEAR With open_basedir and safe_mode Restrictions

less than 1 minute read

You want your website to be as safe as possible. So you'll typically want Open Basedir and Safe Mode to be on. When you're in a shared hosting environment, you'll find that any server administrator with a good sense of security will also have these restrictions in place. However security pretty much always limits functionality and this case is no different. Because what if you are caged in a restricted environment, and you would still like to use shared libraries like the ones provided by PEAR?

You will have to exclude the PEAR directories from the restrictions. This can be done in the virtual host config as follows:

php_admin_value open_basedir /var/www/www.mysite.com/:/usr/share/php/
php_admin_value safe_mode_include_dir /usr/share/php/

Explained

php_admin_value              means we are going to tell php to change a variable
open_basedir                 means change to which paths your scripts are limited
/var/www/www.mysite.com/     is    where your site can be found
:                            means "also"
/usr/share/php/              is    where your PEAR library can be found

php_admin_value              means tell php to change a variable
safe_mode_include_dir        means ignore owner mismatches in the following directory
/usr/share/php/              is    where your PEAR library can be found

Leave a Comment Right Here