This script is designed to help optimize PHP-FPM configurations by analyzing current system resource usage and PHP-FPM settings. It provides recommendations for the pm.max_children
setting based on available system RAM and the average size of PHP-FPM child processes. Additionally, it suggests values for pm.start_servers
, pm.min_spare_servers
, and pm.max_spare_servers
based on the number of CPU cores. This script is intended for systems running PHP 7.4.
- Checks for
max_children
reached errors in PHP-FPM logs. - Retrieves current
pm.max_children
and other related settings from the PHP-FPM configuration. - Calculates total available RAM and average PHP-FPM child process size.
- Suggests optimal PHP-FPM
pm.*
settings based on system resources.
- Ensure you have sudo privileges or run as the root user.
- Save the script as
optimize_php_fpm.sh
. - Make the script executable:
chmod +x optimize_php_fpm7_4.sh
. - Run the script:
./optimize_php_fpm7_4.sh
.
The script will output:
- Total system RAM.
- Average size of PHP-FPM child processes.
- Number of CPU cores.
- Recommended settings for
pm.max_children
,pm.start_servers
,pm.min_spare_servers
, andpm.max_spare_servers
.
- This script is specifically for PHP 7.4 FPM running on Linux.
- Adjustments to the PHP-FPM configuration file (
/etc/php/7.4/fpm/pool.d/www.conf
) based on the script's recommendations should be done carefully and with understanding of the potential impact on your specific environment. - Always backup your configuration files before making changes.