Apache VirtualHosts define php.ini but extend main php.ini

Posted by Hosh Sadiq on Server Fault See other posts from Server Fault or by Hosh Sadiq
Published on 2013-07-02T19:36:11Z Indexed on 2013/07/03 5:08 UTC
Read the original article Hit count: 581

Filed under:
|

I have a main php.ini file and am wondering if it is possible to specify a custom php.ini for a virtualhost, but this php.ini would extend the main php.ini file, so that only the specified settings are overridden and everything else is taken the main php.ini. For example:

I have my main php.ini file in /etc/php5/php.ini, containing all the defaults. Let's say this has everything as default so e.g.

allow_url_fopen = On
allow_url_include = Off

Then I have my virtualhost located at /home/user/php.ini and this contains the following:

allow_url_fopen = Off

This php would run with first the php.ini in /etc/php5/php.ini then the settings that are in /home/user/php.ini resulting in a configuration where both allow_url_fopen and allow_url_include are set to Off.

Edit: Also, if /home/user/php.ini does not exist, it would default back to /etc/php5/php.ini

© Server Fault or respective owner

Related posts about apache2

Related posts about php.ini