cPanel & WHM Version 94 has been released, and brings a slew of great updates. Take a look at what is included, and then upgrade today!

PHP-FPM Enhanced Configuration

Hutina Teodor Silviu shared this idea 4 years ago
Completed

At the moment we can't configure PHP-FPM globally for all domains that already have FPM active , we have to change the settings for each domain and only the following settings :


  1. pm.max_children = 5
  2. pm.max_requests = 20
  3. pm.max_spare_servers = 5


Also if we want to add or change new values we have to edit

/var/cpanel/userdata/<CPANEL USERNAME>/<DOMAIN>.php-fpm.yaml for each domains which this is a real pain and will take weeks to do it for a high number of domains.


There are other settings hard coded into cPanel scripts which we can't change :


  1. php_admin_flag[allow_url_fopen] = on
  2. php_admin_flag[log_errors] = on
  3. php_admin_value[disable_functions] = exec,passthru,shell_exec,system
  4. php_admin_value[error_reporting] = E_ALL & ~E_NOTICE
  5. php_admin_value[short_open_tag] = on


We need a way / file to set a globally config file so it can apply for all domains new or old ( php-fpm.d/domain.name.conf ) ( disable_functions , error_reporting , timeout , slowlog on , path , etc... ).


Also as for all the domains the general php-fpm config file is generated by cPanel which we can't easily change.

E.g : /opt/cpanel/ea-php56/root/etc/php-fpm.conf ( emergency_restart_interval , emergency_restart_threshold , process_control_timeout ).


This is really needed for tuning , better performance , easy to control.

Comments (9)

photo
1

Hello,


I sure second that! I had a collateral issue with accounts with dated code logging enormous quantities of Deprecated errors despite the fact that E_DEPRECATED was disabled in the global php.ini but not replicated to the PHP-FPM conf file.

The only way to set this was through the file that you mention. But I sure like to have more options.

Before seeing your request I had posted a very similar one. I will let it be and vote for your's also in hope to have more options plus global options available soon.


Dimitris

photo
1

To change the hard-coded cPanel values, you can create/modify the file /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml and include, for example:


  1. php_admin_flag_allow_url_fopen: { present_ifdefault: 0 }

Or something like that. It's been a little while since I've look at cPanel 60's FPM configuration system.

photo
1

In addition, the part about doing this per domain name is also valid.


Is per-virtualhost pools the best way to go about this? Or would per-system user be a better approach? Probably a little too late to do anything about this now, since cPanel has apparently moved ahead with per-virtualhost pools in cPanel 60.


Per virtualhost pools (or per domain) will give you a lot more flexibility but with the added cost of having to setup pools for each and every VirtualHost. How much of that flexibility is really needed? Per-user pool is going to be a lot easier to set up and maintain (you don't have to set up and remove pools every time a subdomain or addon domain is added or removed). I'm not saying one is better than the other, but something to think about.

photo
1

The value of php_admin_value and php_admin_flag set by default by cPanel is a real problem. They should totally stop doing that, it make PHP-FPM really hard to configure. php.ini directive is more that enough to manage php globally. Those directive are not needed.

photo
1

I, too, have been stung by this problem. I have just had a run-in with cPanel support techs to "fix" a problem which could really be enhanced and configurable via WHM.


By default, display_errors and display_startup_errors are "on" with PHP-FPM. I need to disable those for security, and have edited the relative auto-generated .conf files several times but of course they are periodically discarded upon updates. I hadn't realised the .yaml files hold true configs hence my support ticket.


The whole pesky problem and drama would/could be avoided by simply enhancing the PHP-FPM features available in WHM. Currently in MultiPHP Manager, we have the option to configure max children, idle timeouts and max requests - it would be nice to see this extended to allow full FPM configurations via WHM.


Better still, if we could edit "master" .yaml templates to apply particular settings globally, and then have a regenerate button to build new .conf files with these settings.

photo
2

Hello,


I have found out lately that you can edit the master config :


1) Create the file /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml


Add you custom settings :


  1. php_admin_value_disable_functions : show_source,system,exec,shell_exec,passthru,popen,proc_openphp_admin_value_error_reporting : E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICTpm_max_children : 25pm_max_requests : 50pm_min_spare_servers : 1pm_max_spare_servers : 25pm_process_idle_timeout : 5

Then regenerate all domains.


rm -rf /var/cpanel/userdata/*/*.php-fpm.yaml

/scripts/php_fpm_config --rebuild

photo
2

With PHP-FPM enabled by default on account creation now in pre-release - https://features.cpanel.net/topic/php-fpm-enabled-by-default-on-account-creation#comment-52298


Would we be able to have a possible ETA for this request? It's going to become quite an important and demanded feature for those enabling FPM by default.

photo
1

I've also found that if I have existing customizations in a domain's php-fpm.yaml file, those changes are lost if I change the version of PHP used for the domain, such as upgrading from PHP 7.0 to 7.1. So, please make sure to preserve manual changes to these files.

photo
1

V78 had solved these problems. Just check WHM => Software => MultiPHP manager => System PHP-FPM configuration. If I am not wrong all mentioned errors fixed even the global pool options and a lot mentioned disrespected php ini error log settings which i have also hated. Now its much better than before!

photo
1

It's true, these improvements were adding in cPanel & WHM Version 78!

https://documentation.cpanel.net/display/78Docs/78+Release+Notes#id-78ReleaseNotes-ConfiguresystemPHPINIdirectivesforPHP-FPMfromWHM'sMultiPHPManagerinterface

If you have any other questions or concerns, don't hesitate to reach out!

Replies have been locked on this page!