How to use different php.ini files for different VirtualHosts?

Posted by gsingh2011 on Pro Webmasters See other posts from Pro Webmasters or by gsingh2011
Published on 2012-05-27T20:56:08Z Indexed on 2012/05/30 17:01 UTC
Read the original article Hit count: 253

Filed under:
|
|
|
|

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.

© Pro Webmasters or respective owner

Related posts about php

Related posts about apache