PHP-FPM Domain Pools
Last modified: 2021 January 18
Overview
This document explains how the system creates a domain pool with PHP-FPM.
How does the system create pools?
The system creates a pool when the /var/cpanel/userdata/[user]/[domain].php_fpm.yaml configuration file exists in the domain. This file must include the following lines:
|
|
You may place any desired pool values in this file.
- You must include the
---line above the pool values in this file. - The
_is_presentvalue is optional, but you must include it if you do not set any other values in the file.
.yaml files. Incorrect syntax in these files will cause services to fail. We strongly recommend that you create a backup of your system before you manually edit .yaml files.
Create a pool
To create a pool, run the Cpanel::PHPFPM::rebuild_files() function.
/scripts/php_fpm_config --rebuild script to create a pool.
The system will perform the following steps:
-
The system scans for the
/var/cpanel/ApachePHPFPM/system.yamland/var/cpanel/ApachePHPFPM/system_pool_defaults.yamlfiles and then generates a system configuration for each of the PHP versions. -
The system searches for the domain’s
yamlfiles. -
The system generates a line in the
/opt/cpanel/[ea_php_version]/root/etc/php-fpm.d/[domain].conffile for everydomain.yamlfile. -
To direct the requests to the
php_fpmdaemon with Apache, the system modifies thehttpd.conffile with therebuild_files()script to resemble the following example:
|
|
The system removes any existing conf files that do not contain a corresponding domain.yaml file.
The system creates the FPM socket in the /opt/cpanel/phpversion/root/usr/var/run/php-fpm/obscure_domain.sock directory, where phpversion represents the version of PHP, and obscure_domain represents a hashed version of the domain. Your hashed version will resemble the following example:
/opt/cpanel/ea-php56/root/usr/var/run/php-fpm/4cfb2f15c04ae8a6a980ad6b78a834e7c8661958.sock
When the pool and system configurations exist in their designated locations, the system restarts the pools. The method that the system uses to restart them depends on whether it runs as a systemd or an init.d system. The system then removes any PHP version pools that do not hold domains with that version.
Jail shell
When you create a PHP-FPM domain pool, if the following conditions exist, the system automatically binds them to the virtfs mount:
- The
/var/cpanel/feature_toggles/apachefpmjailfile exists. - The WHM account uses either the
jailshellornoshellsettings. - You enabled the Experimental: Jail Apache Virtual Hosts using mod_ruid2 and cPanel® jailshell setting in the Security section of WHM’s Tweak Settings interface (WHM » Home » Server Configuration » Tweak Settings).