• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Adjust php-fpm settings in Plesk 12.5

brainforge

Basic Pleskian
What is the correct way of adjusting php-fpm settings?

At a domain level they are stored here:
/opt/plesk/php/5.6/etc/php-fpm.d/mydomain.com.conf

Usual warning about 'DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY'.
Where is Plesk panel can this be configured?

For example iIf I add pm.max_children = 2 to the domain PHP settings I get the following line add to the above conf file.
php_value[pm.max_children] = 2

It does not change the php-fpm setting of pm.max_children = 5 which is a few lines previously.
 
To edit your PHP settings at the domain level, you'll want to log into the control panel, find the domain and edit the PHP settings. From there you'll be able to add your custom directive under the Additional Configuration Directive.

If you want to edit it server wide, from within the control panel, go to Tools & Settings > PHP Settings > the PHP version you're trying to edit (make sure you choose the one that says FPM Application) > PHP.ini. From there you can edit it so it affects the whole server as long as they don't have the setting at the domain level (any directive set at the domain level overrides any settings set at the server level).
 
Thanks, we seem to have misunderstood each other here.
I have no problem with changing the PHP.ini settings, its safely changing the FPM settings in these files which are the difficulty:

/opt/plesk/php/5.6/etc/php-fpm.conf
/opt/plesk/php/5.6/etc/php-fpm.d/mydomain.com.conf

See attached PDFs.
The values in php-fpm.conf are overriden by the values in mydomain.uk.conf
 

Attachments

  • mydomain.uk.conf.pdf
    49.1 KB · Views: 27
  • php-fpm.conf.pdf
    53.8 KB · Views: 37
No, there's no misunderstanding, if you want to be able to change anything at the domain level, you have to do it through the control panel and not directly via SSH. Please re-read what I said where I said "To edit your PHP settings at the domain level, you'll want to log into the control panel, find the domain and edit the PHP settings. From there you'll be able to add your custom directive under the Additional Configuration Directive."

I've attach a screenshot of what the screen will look like.

edit: attached another screenshot of what page you need to be on where you'll find PHP settings
 

Attachments

  • screencapture-www-simon-soft-com-8443-smb-web-php-settings-id-1-1449850004705.png
    screencapture-www-simon-soft-com-8443-smb-web-php-settings-id-1-1449850004705.png
    378.2 KB · Views: 72
  • Capture.PNG
    Capture.PNG
    75.3 KB · Views: 58
Sorry, still got a problem here and confusion between php.ini directives and php-fpm.conf setttings.
Consider:

Looking at file:
/opt/plesk/php/5.6/etc/php-fpm.d/mydomain.uk.conf​
as generated by Plesk and unmodified by me I have these lines:

; By default use ondemand spawning (this requires php-fpm >= 5.3.9)
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
; Following pm.* options are used only when 'pm = dynamic'
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1​

On a live server/site I restart php-fpm using (or use Plesk services restart, makes no difference):
sudo service plesk-php56-fpm restart

Looking at htop output after a few minutes I have up to 5 processes showing the command as:
php-fpm: pool mydomain.uk​
Each of these processes consume anything between 0 and 100% of CPU, they are born and die as needed.
What I see is consistent with and what I would expect using the pm.* settings show above.

------------------------------------------------------------------------------------

I then change the file (i.e. the Plesk do not do this message way) so I have:
pm.max_children = 1​
Then restart php-fpm as above.

Now after a few minutes htop shows me a single php-fpm: pool mydomain.uk process consuming up to 100% CPU.
And this is consistent and what I would expect with this pm.max_children settings.

------------------------------------------------------------------------------------

I return the file to its original state, as at top, and restart php-fpm.
Everything back to normal as it was originally.

Then go to domain PHP settings in Plesk Panel.
Add following line to PHP Additional configuration directives.
pm.max_children = 1​
Click OK or Apply buttons.
In htop see php-fpm processes restart.
After a few minutes I still have the 5 php-fpm: pool mydomain.uk processes NOT the single one I expected.

Restart php-fpm as above, just in case, still no success.

Look at the mydomain.uk.conf file and find that Plesk has not changed the pm.max_children line but instead added the following line at the end of the file along with any additional configuration directives that have been entered.
php_value[pm.max_children] = 1​
I.E Plesk is treating it as a php.ini directive customisation not a PHP-FPM setting!

------------------------------------------------------------------------------------

So still back with the original question.
How can I change the PHP-FPM settings for a domain without breaking the rules and editing a file Plesk tells me not to!

The only way around this I can see is to change the file:
/opt/plesk/php/5.6/etc/php-fpm.conf​
adding the following line at the end:
include=/opt/plesk/php/5.6/etc/php-fpm-mydomains.d​

This file won't get overwritten by domain changes through Plesk panel BUT I suspect I could sometimes lose my extra line(s) during a Plesk update.
So not a good long term solution and also something someone could trip up on.

Was hoping the much improved Plesk 12.5 would get rid of a previous php-fpm configuration muddle on an earlier version elsewhere!
 
Looking at this file again...
/opt/plesk/php/5.6/etc/php-fpm.d/mydomain.com.conf

It has the following comments at the top:
; ATTENTION!
;
; DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
; SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

; If you need to customize this file, use either custom PHP settings tab in
; Panel or override settings in /var/www/vhosts/system/mydomain.com/conf/php.ini.
; To override pool configuration options, specify them in [php-fpm-pool-settings]
; section of /var/www/vhosts/system/mydomain.com/conf/php.ini file.​

We've visited the custom PHP settings tab in the panel with no success (as mentioned previously).
But what's this /var/www/vhosts/system/mydomain.com/conf/php.ini file??
Does not exist. Tried creating it with these lines and restarting php-fpm
[php-fpm-pool-settings]
pm.max_children = 1​
Again no success (made sure I restarted the correct php-fpm the domain uses - php 5.6).

The only way I can see of around this is:
The only way around this I can see is to change the file:
# mkdir /opt/plesk/php/5.6/etc/php-fpm-custom.d​
Add following line at end of /opt/plesk/php/5.6/etc/php-fpm.conf
include=/opt/plesk/php/5.6/etc/php-fpm-custom.d​
Create file /opt/plesk/php/5.6/etc/php-fpm-custom.d/mydomain.com.conf
[mydomain.com]
pm.max_children = 1​
Restart php-fpm
Works great!

Now I can look into using this for the FPM slowlogtimeout and other less used options!
http://php.net/manual/en/install.fpm.configuration.php#request-slowlog-timeout
 
Following the instructions on the header of the conf file I was successfully able to override default php-fpm values by creating a custom php.ini file with specific fpm directives in: /var/www/vhosts/system/mydomain.tld/conf/php.ini
Note that the file was non-existent and I needed to create it.

php.ini

Code:
[php-fpm-pool-settings]
pm = dynamic
pm.max_children = 100
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 498

Afterwards I recompiled domains settings /usr/local/psa/admin/sbin/httpdmng --reconfigure-all

I see Plesk created additional lines with my custom settings in: /opt/plesk/php/5.6./etc/php-fpm.d/mydomain.tld.conf
(this is where per-domain fpm settings are stored if using Odin PHP packages), and php-fpm start spawning as I requested.
 
Thanks, I'll stick with my way.
One advantage the customisation is all in one place
/opt/plesk/php/5.6/etc/php-fpm-custom.d/

Code:
# mkdir /opt/plesk/php/5.6/etc/php-fpm-custom.d
Add following line at end of /opt/plesk/php/5.6/etc/php-fpm.conf
Code:
include=/opt/plesk/php/5.6/etc/php-fpm-custom.d
Create file /opt/plesk/php/5.6/etc/php-fpm-custom.d/mydomain.com.conf
Code:
[mydomain.com]
pm.max_children = 1
Restart php-fpm (make sure its the correct one!)
Code:
sudo service plesk-php56-fpm restart
 
That all okay, but how to create this settings for all domains ? doing this for every1 domain have a little sense.
 
anyone can help ?

How we can change default settings as "pm.max_children = 5" for all vhosts ? there is no problem to do it for php 5.5 in /etc/php5/fpm but its impossible for /opt/plesk/php/5.6/etc
 
anyone can help ?

How we can change default settings as "pm.max_children = 5" for all vhosts ? there is no problem to do it for php 5.5 in /etc/php5/fpm but its impossible for /opt/plesk/php/5.6/etc
did you read on kb on plesk
 
KB article 128965 suggests that this functionality will be available in Onyx. However I've upgraded a test machine and have not found these options anywhere. Am I overlooking this setting?

Currently we're editing options in the files manually and then using
Code:
chattr +i
to make the file immutable so it won't be reverted by Plesk.
 
i have add (see image) additional directives from domain but i think that dont works
 

Attachments

  • Bildschirmfoto 2016-12-15 um 16.42.25.png
    Bildschirmfoto 2016-12-15 um 16.42.25.png
    80.7 KB · Views: 40
Yes, with Plesk it is always "expected" to be implemented and never really implemented. Proof of that, among other things, is their plesk.uservoice.com. There are requests with "Started" label which aren't implemented even after 4 years. Even if a feature request has more than 600 votes it doesn't matter. They still may choose to implement a feature with less than 200 votes. Good work Plesk. You guys are totally unpredictable. Even when you make promises.
 
Back
Top