3

I've made changes to my php.ini file, so I don't update the php.ini file whenever I update the PHP package. I'd like to "fork" off my changes to a different file, so I can update the actual php.ini file without losing my changes.

I realise PHP 5.3 introduced per-directory .ini files, but my server has multiple virtual hosts - therefore multiple document roots - therefore there isn't one place I can put an overriding php.ini file using the per-directory approach.

Is there a way to get PHP to check for an "ammending" php.ini file?

2 Answers2

2

PHP loads additional .ini files from a certain directory. On a Debian 8 box, that directory is: /etc/php5/apache2/conf.d.

Files in that directory are loaded in alphabetical order, so naming a file 00-overrides.ini (for example) will cause it to be loaded first. Settings set in that file will override settings set in the default php.ini.

0

If you're running PHP as an Apache module, there's a directive to set the directory path where PHP will look for php.ini:

LoadModule php5_module "c:/php/php5apache2.dll"
AddHandler application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"

The example is for windows, but works the same for linux systems.

Note that the php.ini in the specified location will replace the php.ini in the default location, it will not override or extend it in any way.

This way when you update PHP it will overwrite the php.ini in the default location, but not your custom php.ini

Reference: http://php.net/manual/en/install.windows.apache2.php#install.windows.apache2.module

fholzer
  • 111
  • Thanks, but I very much want to be able to override settings in the default php.ini, without replacing the file. – Quasipickle May 06 '15 at 20:47