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
May I recommend this alternative approach, which works quite well for multiple different virtualhost sites:
Override specific php.ini files via virtualhost variables. For example, my current web server has these php.ini overloading values:
In this way you can bundle your php.ini config values with your apache config for specific sites, and have custom php.ini values per virtualhost.