3

Shortly: how can I include the same settings across several php-fpm pools without repeating them for each pool?

Details

In php5-fpm there are global directives and per pool directives. In all examples and documentation, each pool has all required settings, e.g.

[www]
user = $pool
group = $pool
listen = 127.0.0.1:9001
listen.owner = $pool
listen.group = $pool
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 30s
chdir = /var/www/$pool

[www2]
user = $pool
group = $pool
listen = 127.0.0.1:9002
listen.owner = $pool
listen.group = $pool
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 30s
chdir = /var/www/$pool

As you can see, most of the configuraton is the same, so I wonder if there is a way to put that configuration in a place where all pools can implicitly or explictly include them.

Just putting them at the bottom of the [Global] section is not working.

Thank you for any suggestion.

  • You mean like in global section? – Michael Hampton Dec 7 '15 at 16:13
  • If I just add pm configuration at the end of the main "php-fpm.conf" file, it is not included. I get the process manager is missing (static, dynamic or ondemand). I guess that's because that's a "per pool" type of setting. – Francesco Abeni Dec 7 '15 at 16:31
8

After trials and errors, I found that you can safely use the include directive to, well, include settings :-)

I created an additional /etc/php5/fpm/common.conf file:

user = $pool
group = $pool
listen.owner = $pool
listen.group = $pool
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 30s
chdir = /var/www/$pool

And now all my pools can be as simple as this:

[www]
listen = 127.0.0.1:9001
include = /etc/php5/fpm/common.conf

[www2]
listen = 127.0.0.1:9002
include = /etc/php5/fpm/common.conf

Additional notes:

  • yes, you have to specify the full path to the common file, because current path for fpm process is NOT the pool.d folder

  • yes, all interpolation is done, so $pool becomes www or www2 at runtime

Hope this could be also useful to someone else.

| improve this answer | |
  • any idea why it doesn't work on php-fpm7.2? I get: ERROR: [/etc/php-fpm-7.2.d/common.conf:1] unknown entry 'user' – Nizar Blond Nov 7 '18 at 16:13
  • 1
    @NizarBlond according to current documentation user is still a valid entry: php.net/manual/en/install.fpm.configuration.php. So I guess something else must be wrong in your configuration file. – Francesco Abeni Nov 8 '18 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.