Overview
This document explains the process by which the system establishes a domain pool using PHP-FPM.
How System Creates Pools
A PHP-FPM domain pool is created when the configuration file located at /var/cpanel/userdata/[user]/[domain].php_fpm.yaml is present within the domain. This file is required to contain the following structure:
You can specify any desired pool values within this file.
- The
---line must be included directly above the pool values. - The
_is_presentvalue is optional; however, it must be included if no other values are defined in the file.
Warning: It is crucial to exercise extreme caution when manually editing .yaml files, as incorrect syntax can lead to service failures. We strongly advise creating a system backup before performing any manual edits to these files.
Note: This file exclusively defines directives that deviate from the built-in default settings.
Create a Pool
To initiate the creation of a PHP-FPM pool, execute the Cpanel::PHPFPM::rebuild_files() function.
Note: Alternatively, the /scripts/php_fpm_config --rebuild script can also be used to create a pool.
The system proceeds through the following steps:
- The system scans for
/var/cpanel/ApachePHPFPM/system.yamland/var/cpanel/ApachePHPFPM/system_pool_defaults.yamlfiles, subsequently generating a system configuration for each installed PHP version. - The system then searches for the domain's corresponding
.yamlconfiguration files. - For each
domain.yamlfile, the system generates a corresponding line in the/opt/cpanel/[ea_php_version]/root/etc/php-fpm.d/[domain].conffile. - To effectively route requests to the
php_fpmdaemon via Apache, therebuild_files()script modifies thehttpd.conffile to appear as demonstrated in the following example:
|
|
Note: Any existing .conf files that lack a corresponding domain.yaml file are subsequently removed by the system.
The FPM socket is established by the system in the /opt/cpanel/phpversion/root/usr/var/run/php-fpm/obscure_domain.sock directory. Here, phpversion denotes the specific PHP version, and obscure_domain is a hashed representation of the domain. An example of a hashed version is provided below:
/opt/cpanel/ea-php56/root/usr/var/run/php-fpm/4cfb2f15c04ae8a6a980ad6b78a834e7c8661958.sock
Once the pool and system configurations are correctly established in their designated locations, the system proceeds to restart the pools. The restart method employed by the system varies depending on whether it operates as a systemd or an init.d system. Following this, the system prunes any PHP version pools that do not contain associated domains.
Jail Shell
When a PHP-FPM domain pool is created, the system automatically binds it to the virtfs mount, provided the following conditions are met:
- The
/var/cpanel/feature_toggles/apachefpmjailfile is present. - The WHM account is configured with either
jailshellornoshellsettings. - The Experimental: Jail Apache Virtual Hosts using mod_ruid2 and cPanel® jailshell setting has been enabled within the Security section of WHM’s Tweak Settings interface (accessible via WHM » Home » Server Configuration » Tweak Settings).
