PHP-FPM settings may be configured at the PHP version + server user level. As in, PHP version andserver users are tied together and PHP-FPM settings are applied to the combination of PHP version + server user.
To update settings, navigate to a site in Cleavr and go to Site Settings.
Click on Update FPM Settings.
From here, you can modify the php-fpm settings.
Be very careful when modifying these settings as some settings are dependent on other settings. After modifying, lookat the PHP error log in server > log to verify that no related errors occur after making the modifications.
Pool reached, consider raising pm.max_children warning
FPM allows for concurrent processes to run. Sometimes, your sites may have more than the default concurrent defaults connections allowed, in which requests willthen be placed in a queue. This can impact visitor performance.
If you look at the PHP error log in the server > log section, you may notice a warning that looks like the following:
WARNING: [pool cleavr] server reached pm.max_children setting (5), consider raising it
You may modify the pm.max_children
setting here.
Calculate pm.max_children setting
A simple calculation for figuring out max children looks like the following:
- Figure out the amount of RAM used for PHP - roughly, total server RAM minus database RAM and other non-PHP processes.
- Figure out the average process size
- Divide RAM for PHP (in Mb) by Avg process size (in Mb)
To figure out average process size, you can run the following command on your server console:
# swap out 8.0 below with version of PHP you are runningps -C php-fpm8.0 -o rss=# Results for this example350361272412724127241272412724127281272812728
In the above output, ignoring the first line (35036), we get a rough average of 12,726 Kilobytes, or ~13 Megabytes.
If in the above example, we have a server that has 1 GB of RAM and 700 Mb is used for PHP, then we'd calculate as:
700 (Mb) / 13 (Mb) = ~54
Therefore, we'd set pm.max_children to 54
We'd want to set the other values as well.
Here is a general breakdown:
pm.max_children = max_childrenpm.start_servers = 25% of max_childrenpm.min_spare_servers = 25% of max_childrenpm.max_spare_servers = 75% of max_children
Applying this to our example, our final settings might look like:
pm.max_children = 54pm.start_servers = 14pm.min_spare_servers = 14pm.max_spare_servers = 41
To reiterate, after changing these configs, check the PHP log in server > logs to make sure there are no errors as a result of making the modifications.
FAQs
Modify the php. ini directives
- Connect to the server via SSH.
- Create the /var/cpanel/ApachePHPFPM directory if it does not already exist.
- Create the /system_pool_defaults. yaml file.
- With a text editor, add your desired PHP-FPM pools. ...
- Regenerate the PHP-FPM configuration files. ...
- Restart Apache and the PHP-FPM services.
How to optimize PHP-FPM pool? ›
An example of PHP-FPM configuration
- Step 1: Determine the maximum number of connection request: ...
- Step 2: Calculate the total number of PHP-FPM processes on the server: ...
- Step 3: Configure the maximum number of PHP-FPM child processes for the server: ...
- Step 4: Set the maximum requests per PHP-FPM process for the server:
Where is the PHP-FPM config file? ›
The configuration file is /etc/php- fpm. conf. By default, php-fpm will respond to CGI requests listening on localhost http port 9000.
What is PHP-FPM used for? ›
PHP-FPM, or “PHP FastCGI Process Manager,” is an advanced, high-performance FastCGI process manager for PHP. It resolves the concurrency issue of PHP's built-in server by spawning multiple workers, which can handle multiple requests simultaneously.
How to check PHP-FPM is running? ›
This can be done from the command line using the php-fpm-status tool. This way, you can check what requests your website is currently processing. You should replace "www.example.com" with the name of your website. The first part of the output shows the same information as the Status section described above.
How to change PHP configuration? ›
When running PHP on Windows, the configuration values can be modified on a per-directory basis using the Windows registry. The configuration values are stored in the registry key HKLM\SOFTWARE\PHP\Per Directory Values , in the sub-keys corresponding to the path names.
Is PHP-FPM good? ›
PHP-FPM is an efficient method on how to minimize the memory consumption and rise the performance for the websites with heavy traffic. It is significantly faster than traditional CGI-based methods in multi-user PHP environments.
Is PHP-FPM faster than mod_PHP? ›
While both PHP-FPM and mod_PHP have their advantages, PHP-FPM is generally faster and more flexible. It doesn't have to start an individual process for each request as mod_PHP does, making it more efficient for serving concurrent requests.
How to set PHP-FPM memory limit? ›
For example, to increase the PHP memory limit:
- Edit the main PHP configuration file at /opt/bitnami/php/etc/php.ini and set the memory_limit variable to a new value, as shown below: memory_limit=NEW_LIMIT.
- Modify the PHP-FPM pool configuration file and set the corresponding variable as follows.
What is the difference between PHP and PHP-FPM? ›
PHP uses a synchronous execution model where each request is handled one at a time by the web server. On the other hand, PHP-FPM uses a multi-threaded approach that allows simultaneous processing of multiple requests.
Step-by-Step Guide to Increase Timeout Limits
- Open the PHP-FPM pool configuration file ( /etc/php/[version]/fpm/pool. d/www. conf ) with a text editor.
- Add or change the request_terminate_timeout parameter: request_terminate_timeout = 300.
- Save the file.
How do I enable FPM in PHP? ›
In order to enable FPM in your PHP build you need to add --enable-fpm to your configure line. There are several other FPM-specific configure options (all of them optional): --with-fpm-user - set FPM user (default - nobody).
What user should PHP-FPM run as? ›
If php-fpm is run as non-root then it will ignore the user and group directives for the pool config and run instead as the current user. Those directives only apply if php-fpm is run as root. The standard php-fpm docker container runs as root but has the pool configured to for www-data .
How many requests can PHP-FPM handle? ›
No - a PHP-FPM process can only handle one request at a time. Usually a process can only handle one task at a time - an exception is with lightweight processes (threads) where the OS process entity has more than one schedulable execution.
What is the alternative to PHP-FPM? ›
HHVM (HipHop Virtual Machine), PHP, NGINX, uWSGI, and JavaScript are the most popular alternatives and competitors to PHP-FPM.
How to configure PHP-FPM with HTTPD? ›
Using Apache HTTPD with PHP-FPM
- Step 1: Install php-fpm. ...
- Step 2: Configure Your php-fpm Pool(s) ...
- Step 3: Start the php-fpm Service. ...
- Step 4: Configure Apache to Use Event Workers. ...
- Step 5: Configure Apache HTTPD to Talk to php-fpm. ...
- Step 6: Add PHP Files to Your Document Root.
Where is PHP-FPM ini? ›
ini file is located at /etc/php/8.1/fpm/php. ini . If you're working with PHP from command line, run the command php --ini to see what php. ini file is being used.
How do I change the PHP version in FPM FastCGI? ›
How to set and change a PHP version
- Go to Settings → Feature → Alternative PHP versions → Edit.
- Select "PHP CGI" in the ISPmanager PHP field.
- Enable the ISPmanager PHP for PHP-FPM option to make this PHP version available for "FastCGI (Nginx + PHP-FPM)".
How do I edit my WP config PHP file? ›
You'll find all of the directories on the left-hand side – select the public_html directory. From here, search the directory for the wp-config. php file. Once you locate it, right-click on it and select the Edit option.