Mobile app version of vmapp.org
Login or Join
Angela700

: How to use different php.ini files for different VirtualHosts? I have my site and it's staging subdomain running on the same CentOS machine running apache. The subdomain is created using a VirtualHost,

@Angela700

Posted in: #Apache #Apache2 #HttpdConf #Php #Virtualhost

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.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Angela700

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo487

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme