Php-fpm and custom php.ini file - how to - need a bit help

SYSTEM INFORMATION
OS type and version UBUNTU 22.04 LTS
Webmin version 2.013
Virtualmin version 7.5 Pro

I already set up Virtualmin with custom php.ini file, and it’s works perfectly with FCGId. My question is, how can i setup it with FPM?
I already use the " Template PHP 8.1 configuration file" directive and it’s works fine - custom ini file created, but if i change the “PHP script execution mode” to FPM the custom file is not loaded.

I had made a try with “Additional FPM pool options” box and add the following line:
include = ${HOME}/etc/php.ini
but it’s just cause an error (of course because it’s a php.ini not an fpm config file). But i can’t find any documentation about how can i setup FPM with my per domain custom php.ini files.

thanks for your help,

Did You read the docs?.
Note: Changing /etc/php.ini will not effect changes in the php.ini of individual virtual servers, e.g. /home/mydomain.com/etc/php.ini. The php.ini of individual virtual servers have to be modified by hand, or via sed or similar command line editing tools, if required. There is no safe way of implementing global changes to all php.ini files. On some systems, there is an /etc/php.d directory, where files that are automatically included by the default php.ini. Thus, you may be able to make system-wide changes by creating a new ini file in this directory containing your directives.

Hello stefan1959,

Sorry i was not clear. I used separated php.ini file for each virtaulhost (from /home/$username/etc/ folders - because every ini file is different), and it’s works perfectly well with php fcgid, but if i want use FPM execution mode, i have no idea how can i tell the webserver to load the user’s php.ini file not the global one. I thought it’s a pretty trivial issue but i can’t find it in the documentation.

best wishes,

Not sure then sorry. I thought FPM used php.ini

P.S. There is a php.ini next to the config file
image

@smartvirtualmin,

PHP-FPM uses a “pool” configuration rather then the “php.ini” file found inside the home directory of the domain.

Navigate to “Virtualmin > Services > PHP-FPM Configuration”

This is where you make customizations.

1 Like

@tpnsolutions has the right answer !! To expand a bit, on that panel at the top it shows (at least on my RedHat systems) the actual path/filename of the config file for the specific virtual server. And it has a button to manually edit that file – of course as always, when you manually edit the file there will be no syntax checking – so its easy to make a mistake and mess things up BIG TIME. Of course having discovered the actual file, you can also edit it by hand with your favorite linux text editor. If you do edit it outside of VirtualMin, be sure later to reload/restart the php-fpm service so that you changes will be read and implemented.

One ‘bug’ or non-feature I recently found – when modifying anything on that panel, such as max file upload size, if you later change PHP versions (if you have multiple versions installed), those settings are NOT carried over !! So be very sure to write down any customizations you have done so that you can re-do them after changing versions !!

Also note these config files have a totally different format than the php.ini files you are used to – you cannot simply copy a php.ini file into these xxxx.conf files :slight_smile:

Found the solution in using user.ini as one of my security app uses it.

https://www.php.net/manual/en/configuration.file.per-user.php

You need to edit the .htaccess file to have
<Files ".user.ini"> Require all denied </Files>

create the file and added the detectives you need.
The format is about the same. I tested and this works, no semi-colan at end
upload_max_filesize = “50M”

This is intensional as a new version of PHP may not support all the settings for a the previous version, so yeah, you’d have to take notes of what you adjusted and make sure that the former settings are either supported or haven’t changed in the new version.

In briefly looking at the VirtualMin Resource Limits panel for my test server in comparing 7.3, 7.4, 8.0 and 8.1, the panel shows the same six items, making me think all six items are available in all those versions. And (again just a brief glance) I cannot see where the VM source code differentiates between any of the versions – that is, it appears the same code is used for any/all versions.

If so, then my idea of having these settings ‘stick’ from version to version may not be so crazy :slight_smile: And if this idea is implemented, then perhaps checks for missing variables/settings in future PHP releases would be in order, or messages/warnings when incompatible future versions are detected on a server.

@verne,

It’s possible that some features would stay the same between versions, however just assuming they would, would be dangerous as major and even minor changes to the PHP code base may add, replace or remove configurations.

Copying configs from 7 to 8 could result in a broken installation if old configs have changed or were removed in the newer version which is likely why this is not the case presently.

That doesn’t mean a method couldn’t be developed to compare and apply old configs if they exist in a newer version…

Definitely worth considering, though I’m not sure where this would fit in terms of priority.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.