Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 1.62 KB

optimize_php_fpm7_4.md

File metadata and controls

34 lines (23 loc) · 1.62 KB

PHP-FPM Optimization Script

Description

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.

Features

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

Usage

  1. Ensure you have sudo privileges or run as the root user.
  2. Save the script as optimize_php_fpm.sh.
  3. Make the script executable: chmod +x optimize_php_fpm7_4.sh.
  4. Run the script: ./optimize_php_fpm7_4.sh.

Output

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, and pm.max_spare_servers.

Note

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