This Bash script is designed to optimize PHP-FPM settings based on your system resources. It detects installed PHP versions, displays current and proposed settings, and allows you to choose which versions to optimize.
- Root access
- Installed PHP-FPM versions
- Detects installed PHP-FPM versions
- Calculates system resources (total RAM, CPU cores, average PHP-FPM process size)
- Calculates recommended PHP-FPM settings (pm.max_children, pm.start_servers, pm.min_spare_servers, pm.max_spare_servers, memory_limit)
- Displays current and recommended settings for each detected PHP version
- Allows you to choose which PHP versions to optimize
- Creates backups of configuration files before making changes
- Restarts PHP-FPM services after optimization
To use this script, simply execute it from the command line:
wget https://raw.githubusercontent.com/egubaidullin/scripts/main/optimize_php.sh && bash optimize_php.sh
or
wget https://raw.githubusercontent.com/egubaidullin/scripts/main/optimize_php.sh
chmod +x optimize_php.sh
./optimize_php.sh
- Check if the script is run as root.
- Detect installed PHP versions.
- Calculate system resources and recommended settings.
- Display current settings and recommended changes for all versions.
- Prompt the user to select PHP versions to optimize.
- Optimize the selected PHP versions:
- Create backups of configuration files.
- Update pool configuration and PHP memory limit.
- Restart PHP-FPM service.
- Confirm the completion of the optimization process.