BuycPanel Blog

BuycPanel Blog

Latest news and updates

How do you Create a User Pool with PHP-FPM?

Posted by Allura on 29 01 2019.

Introduction
This document illustrates the creation of user pool with PHP-FPM by the system.How Does the System Create Pools?
The pools are created when the /var/cpanel/userdata/[user]/[domain].php_fpm.yaml configuration file exist in the domain. File must include the lines given below:—_is_present: 1Any desired pool values can be placed in this file, including the — line above the pool values. Although _is_present value is optional, but needs to be included in case one did not set any other values in the file.One must be aware when they manually edit .yaml files. Incorrect syntax will lead the services to failure. Hence, it is strongly recommended to create a backup of your system before manually editing .yaml files.Keep a note that this file only comprises the differences of directives from the built-in default directives.Create a Pool
One can run the Cpanel::PHPFPM::rebuild_files() function or /scripts/php_fpm_config –rebuild script in order to create a pool.
Steps:The system will scan for the…

Introduction

This document illustrates the creation of user pool with PHP-FPM by the system.

How Does the System Create Pools?

The pools are created when the /var/cpanel/userdata/[user]/[domain].php_fpm.yaml configuration file exist in the domain. File must include the lines given below:

_is_present: 1

Any desired pool values can be placed in this file, including the — line above the pool values. Although _is_present value is optional, but needs to be included in case one did not set any other values in the file.

One must be aware when they manually edit .yaml files. Incorrect syntax will lead the services to failure. Hence, it is strongly recommended to create a backup of your system before manually editing .yaml files.

Keep a note that this file only comprises the differences of directives from the built-in default directives.

Create a Pool

One can run the Cpanel::PHPFPM::rebuild_files() function or /scripts/php_fpm_config –rebuild script in order to create a pool.

Steps:

  1. The system will scan for the /var/cpanel/ApachePHPFPM/system.yaml and /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml files and thereafter generate a system configuration for each of the PHP versions.
  2. The system will proceed in searching the domain’s yaml
  3. System will then generate a line in the /opt/cpanel/[ea_php_version]/root/etc/php-fpm.d/[domain].conf file for each yaml file.
  4. The system will modify the conf  file with the rebuild_files() script in order to direct the requests to the php_fpm daemon with Apache.

The system however, will remove any conf files that is existing and do not have a corresponding domain.yaml file.

The FPM socket is created by the system in the /opt/cpanel/phpversion/root/usr/var/run/php-fpm/obscure_domain.sock directory. Here, the phpversion denotes the version of PHP, and obscure_domain denotes a hashed version of the domain which will resemble the following example:

/opt/cpanel/ea-php56/root/usr/var/run/php-fpm/4cfb2f15c04ae8a6a980ad6b78a834e7c8661958.sock

The system will restart the pools when the pool and system configurations will exist in their designated locations. The whole procedure of restarting method depends on whether it runs as a systemd or an init.d system. The system will then eliminate any PHP version pools that do not hold domains with that version.

Jail Shell

After creating the user pool, the system naturally binds them to the virtfs mount if these conditions exist as mentioned below:

  1. If /var/cpanel/feature_toggles/apachefpmjail file
  2. If the WHM account makes a use of either the jailshell or noshell settings.
  3. If the user enabled this 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).

Conclusion

Everything about the creation of a user pool with PHP-FPM is outlined in this article.