kvz.io
Published on

Use PEAR With open_basedir and safe_mode Restrictions

Authors
  • avatar
    Name
    Kevin van Zonneveld
    Twitter
    @kvz

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

Legacy Comments (3)

These comments were imported from the previous blog system (Disqus).

Daniel
Daniel·

Thanks for sharing that. Every now and than (usually I do not install software on a daily base) I come across some restrictions with regards to safe_mode. Your post will now be my reference for exactly these cases.

Pat
Pat·

Great article !
You've saved my life.

Maurice
Maurice·

The "safe_mode_include_dir = /usr/share/php" entry in the php.ini did solved my issue, big thanks for pointing me the right direction :)