PHP-FPM Settings for Better Optimization

After enabling PHP-FPM (PHP-FastCGI Process Manager) on your VPS, you’ll need to know how to restart the PHP-FPM service and modify its settings. Below we cover how to adjust PHP-FPM settings according to traffic load per cPanel account.

  1. Login WHM as Root.
  2. From the menu, search and select MulitiPHPManager.
  3. Enable PHP-FPM

    Select Turn on to enable PHP-FPM for all cPanel accounts. Alternatively, you can select the checkbox beside specific domains at the bottom, choose On from the dropdown menu beside PHP-FPM, and select Apply.
    You can also change the PHP version here instead of in cPanel.

  4. Select Pool Options beside the specified domain.
  5. Edit PHP-FPM settings

    Modify PHP-FPM settings for the domain. Below are commonly successful changes according to amount of traffic your VPS receives.

    Traffic LoadAverageHeavy
    Max Children25-3540-60
    Process Idle Timeout100100-150
    Max Requests200-350400-600

Edit Default PHP-FPM Settings

If you have many cPanel accounts, you may prefer to change the default settings for newly created cPanel accounts.

  1. As root, SSH into your server or launch WHM terminal.
  2. Create a system_pool_defaults.yaml file in the /var/cpanel/ApachePHPFPM directory. To do this using nano, type the following:
    nano /var/cpanel/ApachePHPFPM/system_pool_defaults.yamlAdd the following to the new file:php_value_error_reporting: 'E_ALL'
    pm_max_children: 500
    pm_max_requests: 2000
    pm_min_spare_servers: 1
    pm_max_spare_servers: 25
    pm_process_idle_timeout: 150
    php_value_disable_functions: 0

    pm_max_children:
    Max number of child processes
    pm_max_requests: Number of requests a child process executes before respawning.
    pm_min_spare_servers: Minimum idle server processes
    pm_max_spare_servers: Maximum idle server processes
    pm_process_idle_timeout: Time until an idle process is killed in s(econds), m(inutes), m(inutes), h(ours), or d(ays).
    php_value_disable_functions: Functions to disable. This doesn’t overwrite php.ini settings.
  3. Save and exit the file. Using nano, press Control and x for the save prompt before exiting. Press y, then Enter ⤶ to save the file.
  4. Rebuild PHP-FPM using the following command:
    /scripts/php_fpm_config --rebuild
  5. Restart PHP-FPM using the following command:
    /scripts/restartsrv_apache_php_fpm

    Note:You can also restart PHP-FPM from WHM.

These adjustments should help you make the most out of your VPS optimization and PHP hosting. You can learn more configuration options for PHP-FPM with official cPanel documentation. You can read more about the benefits of PHP-FPM in our in-depth article.

InMotion Hosting Contributor
InMotion Hosting Contributor Content Writer

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

8 thoughts on “PHP-FPM Settings for Better Optimization

  1. Average
    Why is this change from
    Max Children 300
    Process Idle Timeout 100
    Max Requests 200
    Thank you. Beofre is like this now is changed.

    1. It is possible that the server configuration may have changed as they are periodically updated. The configuration or recommended configurations may have changed as well. For more information, please submit a ticket to our live technical support team. Thank you.

  2. What’s a good way to determine our site’s Traffic Load, per Step 5 of the WHM approach? Right now our site has the default values for Max Children, Process Idle Timeout, and Max Request. Is there a quantitative way to determine what these should be or would arbitrarily picking a number within the suggested range suffice?

    1. It will depend on your actual traffic and how they’re using your site. For example, you can have only a few children but they are making a lot requests, or maybe you’re having a lot of children and they are making only a few requests. My advice would be to speak with an experienced website administrator who can give you an accurate answer to your question based on your data. You are also welcome to submit a support ticket to our live technical support team for further information.

Was this article helpful? Join the conversation!