How to change PHP-FPM pool settings for a domain in Plesk

Created:

2016-11-16 13:16:35 UTC

Modified:

2017-08-22 08:48:11 UTC

15

Was this article helpful?


Have more questions?

Submit a request

How to change PHP-FPM pool settings for a domain in Plesk

Applicable to:

  • Plesk 12.5 for Linux
  • Plesk Onyx for Linux
  • Plesk 12.0 for Linux

Question

How to change PHP-FPM pool settings for a domain through Plesk UI?

Answer

Currently there is no way to manage these settings through Plesk UI. This feature request is open for voting on UserVoice portal.

It is possible to change PHP-FPM pool settings for a domain through CLI:

  1. Connect to the server using SSH .
  2. Create file /var/www/vhosts/system/example.com/conf/php.ini and define FPM parameters in it. If the file /var/www/vhosts/system/example.com/conf/php.ini doesn't exist, system administrator is to manually create it. Directives should be specified in [php-fpm-pool-settings] section:

    # cat /var/www/vhosts/system/example.com/conf/php.ini
    [php-fpm-pool-settings]
    pm.max_children = 100
    pm.max_requests = 100

  3. Apply new parameters to domain's configuration file:

    Go to Domains > example.com > PHP Settings and click Apply without changing any settings

    or

    Run the following command to update PHP parameters:

    # /usr/local/psa/bin/php_settings -u

    After that the required changes will overwrite pool settings. They will be written in /opt/plesk/php/<version>/etc/php-fpm.d/example.com.conf if PHP support for a domain is provided by Plesk in Domains > example.com > PHP Settings :

    alttext

    or in /etc/php-fpm.d/example.com.conf if PHP support for a domain is 'provided by OS vendor' in Domains > example.com > PHP Settings :

    alttext

    If it is required to predefine PHP-FPM pool settings for all newly created domains follow the steps here:

  1. Create script with desired configuration parameters, for example:

    # cat /root/event_handler.sh
    #!/bin/bash
    touch /var/www/vhosts/system/${NEW_DOMAIN_NAME}/conf/php.ini
    echo -e "[php-fpm-pool-settings]\npm = ondemand\npm.start_servers = 3\npm.min_spare_servers = 3\npm.max_spare_servers = 8\npm.max_children = 35\n" > /var/www/vhosts/system/${NEW_DOMAIN_NAME}/conf/php.ini
    /usr/local/psa/bin/domain --update-php-settings ${NEW_DOMAIN_NAME}

  2. Create custom event handler in Plesk > Tools & Settings > Event Manager > Add Event Handler for event Physical hosting created which will call script from /root/event_handler.sh .

Have more questions? Submit a request

13 Comments

  • 0
    Avatar
    Oliver Burkill

    In /opt/plesk/php/7.0/etc/php-fpm.d/<domain>.conf It says "; Following options can be overridden", however it seems they can't and do get overwritten by Plesk meaning this method is needed.

    In this article I think the two images for Plesk and OS provided PHP are the wrong way round.

  • 0
    Avatar
    Nikolay Zhmuk

    Hi

    > In /opt/plesk/php/7.0/etc/php-fpm.d/<domain>.conf It says "; Following options can be overridden", however it seems they can't and do get overwritten by Plesk meaning this method is needed.

    "; Following options can be overridden" - this comment means that directives below can be overwritten in /var/www/vhosts/system/example.com/conf/php.ini config

    > In this article I think the two images for Plesk and OS provided PHP are the wrong way round.

    Thank you, the article has been updated

  • 0
    Avatar
    Sathish

    If i am using windows plesk onyx how to edit ?

  • 0
    Avatar
    Artyom Baranov

    Hello Sathish,

    > If i am using windows plesk onyx how to edit ?

    This article is not applicable for Plesk on Windows because PHP-FPM handler is only available for Plesk on Linux:

    https://docs.plesk.com/en-US/onyx/administrator-guide/web-hosting/php-management/php-handler-types.75145/

  • 0
    Avatar
    Peter Debik

    The script that creates the php.ini file creates that file, but it does not apply the new settings. It is still necessary to click the "Apply" button in the subscription to reconfigure the php init file of the affected domain for the new default settings to take effect.

    Can that be automated, too, e.g. by adding another event that reconfigures PHP for the newly created domain only AFTER the subscription or add-on domain was created? How?

  • 0
    Avatar
    Konstantin Annikov

    Hi Peter,

    Script was updated, thank you for bringing our attention. 

  • 0
    Avatar
    Peter Debik

    Great. Thank you! Just one minor addition please: The "/usr/local/psa/bin/domain" command needs to start in a new line, then everything is perfect.

  • 0
    Avatar
    Muhammad Hassaan

    I am still getting the following error :(

     

    [29-May-2017 16:59:17] WARNING: [pool instahd.info] child 22843 said into stderr: "ERROR: Unable to set php_value 'pm'"
    [29-May-2017 16:59:17] WARNING: [pool instahd.info] child 22843 said into stderr: "ERROR: Unable to set php_value 'pm.start_servers'"
    [29-May-2017 16:59:17] WARNING: [pool instahd.info] child 22843 said into stderr: "ERROR: Unable to set php_value 'pm.max_children'"
    [29-May-2017 16:59:17] WARNING: [pool instahd.info] child 22843 said into stderr: "ERROR: Unable to set php_value 'pm.max_requests'"
    [29-May-2017 16:59:17] WARNING: [pool instahd.info] child 22843 said into stderr: "ERROR: Unable to set php_value 'pm.min_spare_servers'"
    [29-May-2017 16:59:17] WARNING: [pool instahd.info] child 22843 said into stderr: "ERROR: Unable to set php_value 'pm.max_spare_servers'"
    [29-May-2017 16:59:17] WARNING: [pool instahd.info] child 22843 said into stderr: "ERROR: Unable to set php_value 'listen.backlog'"
    [29-May-2017 16:59:17] WARNING: [pool instahd.info] server reached max_children setting (5), consider raising it

     

    The above solution not working on CentOS 7.3 anymore.

  • 0
    Avatar
    Muhammad Hassaan

    Latest logs

     

    [29-May-2017 17:22:16] WARNING: [pool instahd.info] child 29821 said into stderr: "ERROR: Unable to set php_value 'pm.max_children'"
    [29-May-2017 17:22:16] WARNING: [pool instahd.info] child 29821 said into stderr: "ERROR: Unable to set php_value 'pm.max_requests'"
    [29-May-2017 17:22:16] WARNING: [pool instahd.info] child 29824 said into stderr: "ERROR: Unable to set php_value 'pm.max_children'"
    [29-May-2017 17:22:16] WARNING: [pool instahd.info] child 29824 said into stderr: "ERROR: Unable to set php_value 'pm.max_requests'"
    [29-May-2017 17:22:16] WARNING: [pool instahd.info] server reached max_children setting (5), consider raising it

     

     

  • 0
    Avatar
    Vitaly Zhidkov

    @Muhammad, please post the content of /var/www/vhosts/system/example.com/conf/php.ini

  • 0
    Avatar
    Muhammad Hassaan

    @Vitaly my settings are following

     

    listen.backlog = 65535

    ;[php-fpm-pool-settings]
    pm = dynamic
    pm.max_children = 5000
    pm.start_servers = 50
    pm.min_spare_servers = 20
    pm.max_spare_servers = 70
    pm.max_requests = 2000

     

    I have 64GB of Ram

  • 1
    Avatar
    Vitaly Zhidkov

    @Muhammad, try to remove semicolon before [php-fpm-pool-settings] section and run the following command:

    # /usr/local/psa/bin/php_settings -u

  • 0
    Avatar
    Muhammad Hassaan

    @Vitaly thanks, that works

Please sign in to leave a comment.