Activating a PHP-FPM pool for your cPanel domain will give a hefty performance boost over the default suPHP or CGI handler. But did you know that you can further improve the PHP-FPM performance by tweaking the pool settings? This is not for the faint-hearted however, and requires some sysadmin understanding with SSH access and editing of cPanel YAML files. Here's what we do:
First, locate and open your site's PHP-FPM YAML file in the SSH console. The file location and name structure is as follows:
This is, of course, where 'username' is your cPanel username and 'domain.tld' is your domain name like example.org or google.com.
Once you have your YAML file open, you'll be presented with a basic configuration as per the main cPanel/WHM PHP-FPM interface. Here's where we can improve it. The below example is taken from a busy Wordpress/Magento site, but you can tweak it to your own requirements. Remove all existing YAML file contents and replace with:
php_admin_value_disable_functions : passthru,system
And finally, to apply the settings we need to rebuild the master PHP-FPM pool config files and restart the PHP-FPM processes:
Of course, you should customise this as required:
- Using static PHP children, your server's RAM/memory usage will be consistently higher than prior so you may need to lower the pm_start_servers and pm_max_children values.
- You might also want to increase pm_max_requests, if for example your site serves high volumes of small requests. Or, perhaps decrease it if you serve large memory-hungry requests.
- It is recommended to leave passthru and system disabled for security, and you might also want to disable further functions like ini_set too.
- The display errors flags are disabled also for security and PCI compliance, however for debugging/development sites you may wish to set those.
Hope this helps!