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

Created:

2016-11-16 13:16:35 UTC

Modified:

2017-05-23 00:58:20 UTC

13

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. 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 = 1000
    pm.max_requests = 1000
  2. Apply new parameters to domain's configuration file:

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

or

2.2. 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 = dynamic\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

7 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.

Please sign in to leave a comment.