Override php-fpm pool config values with another file

Solution 1:

Could not find an "official" confirmation from another source, but here is some outcome after doing some research:

Analyzing the source code of php7.0-fpm and more specifically fpm-conf.c, it appears that

  • the main configuration file php-fpm.conf is read first [ fpm_conf_load_ini_file() ],
  • all include directives are read in order, giving a list of files thanks to glob(),
  • each of the file is parsed by the same fpm_conf_load_ini_file(),
  • an entry in the file overwrites any previously set value,
  • any new include will have a recursive call to the includes processing function, and
  • the glob() function sorts names, by default (no GLOB_NOSORT option)

Thus we can assume - at least in this version but this is unlikely to change soon considering the present code - that it is safe to arrange the pool.d directory configuration files in alphabetical order ; any previously recorded value being overwritten by an entry with the same name read after.

We have a clean way to handle configuration files for php-fpm, keeping the distribution ones untouched, and adding custom files having name alphabetically greater than the packaged ones, that contain the few options that have to be changed.

Solution 2:

In case u have some file like php-overrides.ini you should copy it to

/etc/php/7.0/fpm/conf.d/99-overrides.ini

99 prefix is due to order of execution