Php custom settings in mods-available

I have read somewhere, longer time ago, that it is possible to set php settings, you would normally set in the different php.ini files, could also be set in mods-available.

Since then I did this like:
sudo nano /etc/php/8.1/mods-available/custom.ini
here I set some settings like:

opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1

max_execution_time = 300
max_input_time = 600
memory_limit = 1G
upload_max_filesize = 1G
output_buffering = off

and enabled this as:
phpenmod custom
It looks like as this is working.

But I read somewhere else that I should have set an
priority= level in this file. Is that true, or necessary?

And is it possible to set options from the file:
/etc/php/8.1/fpm/pool.d/www.conf
in this custom.ini file?
Like:

[www]
pm.max_children = 83
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 62

Or is that not working here?

It doesn’t seem to be necessary, but that way you can assure that your settings are overriding defaults instead of defaults overriding yours. Check out the other modules, which all have the ; priority=xy line, which leads to symlinks in /etc/php/*/*/conf.d/ having this priority as prefix when enabling the module. Since those are parsed alphanumerically, and same options parsed again override those parsed before, a higher priority has the desired effect. Not sure what happens if you leave it out, does the symlink then have no prefix? In that case it would have highest priority as well since letters are sorted behind numbers, but I’d always try to be better explicit than implicit :wink:.

No, those are FPM settings, no PHP settings. You cannot mix them. But you can create a new config to override www.conf (and php-fpm.conf). Those are as well parsed in alphanumerical order, so use e.g. /etc/php/8.1/fpm/pool.d/zz-custom-www.conf.

Thank you Michalng!
If I set
; priority=99
isn’t that commented out then?

I have transfered the www settings to a separated file custom-www.conf in fpm/poool.d/
Do I have to enable this file, or is this read automatically by php-fpm/fpm?
If I start this section in this custom file with [www] are these settings then added to the config under [www] in www.conf?

Of course, this is not a PHP setting, but only used by phpenmod for sorting the configuration files.

fpm/poool.d/ Do I have to enable this file

No, this dir is directly loaded by PHP-FPM.

If I start this section in this custom file with [www] are these settings then added to the config under [www] in www.conf?

Not sure what you mean by “added”. PHP-FPM generally setups PHP pools according to INI sections it finds in its config file(s). By default php-fpm.conf is given as its config file, and that one contains a directive at its end that it should include all *.conf files below the pool.d directory, which it naturally does in alphanumeric order or later parsed directives override earlier ones, in case. After it parsed all files and internally stored stored all defined pools with settings, it starts the workers accordingly. This is probably a inaccurate when it comes to details, just to explain the general logic of such config file structures.

Thank you @MichaIng / Micha, That is very hulpfull.