I have my site and it's staging subdomain running on the same CentOS machine running apache. The subdomain is created using a VirtualHost, and I use it to find any bugs before I push to production. I want the php.ini file for the staging VirtualHost to be a development one, and the production site will use a production php.ini. How can I configure apache to use different php.ini files? I don't want to use php_value/php_flag for everything, I'd rather just use the php.ini file I already have available. I've tried creating an .htaccess file that looks like this,

SetEnv PHPRC /path/to/php.ini/directory

This has no effect, as phpinfo() tells me it's still using /etc/php.ini. I've also tried setting PHPIniDir for both virtual hosts (www and staging) and it complains about seeing the directive twice.

  • Have you tried setting the PHPIniDir for just the staging and leaving the production side as the default? May 28, 2012 at 15:18
  • You might also check this question/answers.
    – j0k
    Aug 28, 2012 at 14:54

1 Answer 1


Actually, it is impossible to specify different php.ini files for each virtual host.

However you can change almost anything in the php.ini file by using the ini_set() function:

  • It allows you to set the value of a given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.
  • Not all the available options can be changed using ini_set(). There is a list of all available options here. Thus, all directives having the "PHP_INI_USER" mode can be changed during runtime by using the ini_set() function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.