Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Include Page
_Version
_Version

Table of Contents
stylenone

Overview

This document explains how the system creates a user 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 use the following lines at a minimum:

Code Block
---
_is_present: 1

You may place any pool values that you wish within this file. The _is_present value is optional, but is required if you do not set any other values in the file.

Include Page
LIB:_YAMLwarning
LIB:_YAMLwarning

Note
titleNote:

This file only contains the differences of directives from the built-in default directives.


Create a pool

To create a pool, run the Cpanel::PHPFPM::rebuild_files() function. 

Note
titleNote:

You may also run the /scripts/php_fpm_config --rebuild script to create a pool.

The system will perform the following steps for you:

    • The system scans for the /var/cpanel/ApachePHPFPM/system.yaml and /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml files and then generates a system configuration for each of the PHP versions.

    • The system searches for the domain's yaml files.

    • The system generates a line in the /opt/cpanel/[ea_php_version]/root/etc/php-fpm.d/[domain].conf file for every domain.yaml file.
    • To direct the requests to the php_fpm daemon with Apache, the system modifies the httpd.conf file with the rebuild_files() script to resemble the following example:

      Code Block
      languagebash
      linenumberstrue
      # php -- BEGIN cPanel-generated handler, do not edit
      <FilesMatch ".(phtml|php[0-9]*)$">
          SetHandler "proxy:unix:/home/cptest3/cptest3_tld.php_fpm.sock|fcgi://cptest3.tld/"
      </FilesMatch>
      # php -- END cPanel-generated handler, do not edit


      Note
      titleNote:

      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:

Code Block
languagebash
/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 depends on whether it runs as a systemd or an init.d system. The system then shuts off any PHP version pools that do not hold domains with that version.

Jail shell

When you create a PHP-FPM user pool, the system automatically binds them to the virtfs mount when the following conditions exist:

  • The /var/cpanel/feature_toggles/apachefpmjail file exists.
  • The WHM account uses either the jailshell or the noshell settings.
  • 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 (Home >> Server Configuration >> Tweak Settings).

Additional documentation

Localtab Group


Localtab
activetrue
titleSuggested documentation

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel = "php-fpm" and label = "whm" and space = currentSpace()


Localtab
titleFor cPanel users

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel = "php-fpm" and label in ("whm","uidoc") and space = "ALD"


Localtab
titleFor WHM users

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel = "php-fpm" and label in ("whm","uidoc") and space in ("ALD","CKB")


Localtab
titleFor developers

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel = "php-fpm" and space = "SDK"