Search code examples
phpapachevirtualhosthttpd.confopen-basedir

How to disable "ini_set" and "exec" for a particular VirtualHost?


I'm already using open_basedir to restrict a VirtualHost to a certain directory:

<VirtualHost *:80>
  ServerName test.example.com
  DocumentRoot /sites/test/www
  php_admin_value "open_basedir" "/sites/test/www"
  <Directory />
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>

How to disable the use of ini_set or exec, but only for this particular VirtualHost (and not for the others)?


Solution

  • You're looking for the disable_functions entry in your php.ini. So you want a different php.ini for your particular VirtualHost. That could be done via "PHPINIDir"

    <virtualhost *:80>
        ServerName www.example.com
        DocumentRoot /path/to/example.com
        PHPINIDir /whatever/path/to/php.ini
    </virtualhost>
    

    UPDATE: I removed the example with php_admin_value because, as others have noted in the comments, it wouldn't work with this particular setting. As was discussed here: php_admin_value disable_functions not working ( sorry ... should have looked it up beforehand).