{"id":802,"date":"2021-07-23T12:38:31","date_gmt":"2021-07-23T12:38:31","guid":{"rendered":"https:\/\/ssdsunucum.com\/blog\/php-fpm-code-and-filesystem-layout-for-easyapache-4\/"},"modified":"2021-07-23T12:38:31","modified_gmt":"2021-07-23T12:38:31","slug":"php-fpm-code-and-filesystem-layout-for-easyapache-4","status":"publish","type":"post","link":"https:\/\/ssdsunucum.com\/blog\/php-fpm-code-and-filesystem-layout-for-easyapache-4\/","title":{"rendered":"PHP-FPM Code and FileSystem Layout for EasyApache 4"},"content":{"rendered":"<\/p>\n<div class=\"col-md-9\">\n<div class=\"flex-column flex-md-row article-header\"><\/div>\n<hr>\n<h2 id=\"overview\">Overview<\/h2>\n<p>This document explains the following information about the PHP FastCGI Process Manager (PHP-FPM) daemon:<\/p>\n<ul>\n<li>The PHP-FPM filesystem layout.<\/li>\n<li>How the system implements PHP-FPM on your system.<\/li>\n<\/ul>\n<p>PHP-FPM provides an alternative FastCGI daemon for PHP that allows a website to handle significant loads. It allows a host to set specific amounts of resources to process a domain\u2019s requests via workers available to respond to PHP requests (pools). These pools allow a website to process more requests.<\/p>\n<p>PHP-FPM functions more quickly than traditional CGI-based methods, such as SUPHP, for multi-user PHP environments. It does <strong>not<\/strong> overload a system\u2019s memory with PHP from Apache processes, such as the <code>ruid2+php-dso<\/code> process. PHP-FPM <strong>only<\/strong> executes PHP requests, which enables it to service content quicker than other methods.<\/p>\n<div class=\"callout callout-danger\">\n<div class=\"callout-heading\">Warning:<\/div>\n<div class=\"callout-content\">\n        We <strong>strongly<\/strong> recommend that you only activate Apache PHP-FPM if your server has at least 2 GB of RAM available, or at least 30 MB of RAM per domain. If you enable PHP-FPM on a server with less than the required RAM, your server may experience severe performance issues.\n    <\/div>\n<\/div>\n<h2 id=\"php-fpm-implementation\">PHP-FPM implementation<\/h2>\n<p>The <code>Cpanel::PHPFPM (Cpanel\/PHPFPM.pm)<\/code> module provides the basis of EasyApache support with PHP-FPM. The module\u2019s built-in defaults generate configuration files that provide fully functional PHP-FPM pools for a domain.<\/p>\n<p>The system uses the following configuration files:<\/p>\n<ul>\n<li><code>\/var\/cpanel\/ApachePHPFPM\/system.yaml<\/code><\/li>\n<li><code>\/var\/cpanel\/ApachePHPFPM\/system_pool_defaults.yaml<\/code><\/li>\n<\/ul>\n<p>You will need to create these two files manually. To do this, perform the following steps:<\/p>\n<ol>\n<li>\n<p>Create the <code>\/var\/cpanel\/ApachePHPFPM\/<\/code> directory. <\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-perl\" data-lang=\"perl\">mkdir <span style=\"color:#f92672\">-<\/span>p <span style=\"color:#e6db74\">\/var\/c<\/span>panel<span style=\"color:#e6db74\">\/ApachePHPFPM\/<\/span><\/code><\/pre>\n<\/div>\n<\/li>\n<li>\n<p>Create the two files. <\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"color:#a6e22e\">touch<\/span> <span style=\"color:#f92672\">\/<\/span><span style=\"color:#66d9ef\">var<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">cpanel<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">ApachePHPFPM<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">system<\/span>.<span style=\"color:#a6e22e\">yaml<\/span>\n<span style=\"color:#a6e22e\">touch<\/span> <span style=\"color:#f92672\">\/<\/span><span style=\"color:#66d9ef\">var<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">cpanel<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">ApachePHPFPM<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">system_pool_defaults<\/span>.<span style=\"color:#a6e22e\">yaml<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<\/li>\n<\/ol>\n<h3 id=\"file-contents\">File contents<\/h3>\n<p>Each file contains different directives from the built-in values.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>The system does <strong>not<\/strong> require these files to run because the built-in defaults enable the PHP-FPM to run sufficiently.<\/li>\n<li><strong>Only<\/strong> include the differences in directives within these files.<\/li>\n<\/ul><\/div>\n<\/div>\n<p>The following example displays the <code>system.yaml<\/code> file\u2019s contents:<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"color:#f92672\">---<\/span>\n<span style=\"color:#a6e22e\">daemonize<\/span>: <span style=\"color:#a6e22e\">yes<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>This example <strong>only<\/strong> uses a different value than the built-in default for the <code>daemonize<\/code> setting.<\/li>\n<li>The <code>system-pool-defaults.yaml<\/code> file applies the value to each pool that you create.<\/li>\n<li>Each domain in the system requires that you create one pool.<\/li>\n<li>Replace any unacceptable characters such as <code>.[]()<\/code> with an underscore <code>_<\/code>.<\/li>\n<\/ul><\/div>\n<\/div>\n<p>The table below contains examples of unacceptable value names.<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"left\">Old Name<\/th>\n<th align=\"left\">New Name<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"left\"><code>syslog.facility<\/code><\/td>\n<td align=\"left\"><code>syslog_facility<\/code><\/td>\n<\/tr>\n<tr>\n<td align=\"left\"><code>php_admin_value[disable_functions]<\/code><\/td>\n<td align=\"left\"><code>php_admin_value_disable_functions<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>If you prepend any PHP settings with the <code>disable functions<\/code> or <code>disable_classes<\/code> flags, the system will append the new <code>php.ini<\/code> value to the previous one in the user\u2019s <code>.htaccess<\/code> files. For more information, read securephp.net\u2019s FastCGI Process Manager (FPM) documentation.<\/p>\n<\/p><\/div>\n<\/div>\n<h2 id=\"the-filesystem-configuration-files\">The filesystem configuration files<\/h2>\n<p>The system stores the configuration files that control PHP-FPM in the following files:<\/p>\n<ul>\n<li><code>\/opt\/cpanel\/ea-php54\/root\/etc\/php-fpm.conf<\/code>\u2014 This file contains the system configurations of PHP-FPM.<\/li>\n<li><code>\/opt\/cpanel\/ea-php54\/root\/etc\/php-fpm.d\/[domain].conf<\/code> \u2014 This file changes your domain to the domain setting of the website that you use. For example, the <code>cptest1.tld.conf<\/code> domain.<\/li>\n<\/ul>\n<p>The <code>.yaml<\/code> files within the <code>\/var\/cpanel<\/code> directories generate these two files.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>Do <strong>not<\/strong> edit these configuration files manually.<\/li>\n<li>The system duplicates these configuration files for each version that you select.<\/li>\n<li>The <code>\/opt\/cpanel\/ea-php54\/root\/etc\/php-fpm.d\/[domain].conf<\/code> file displays <code>ea-php54<\/code> or <code>php54<\/code> as its version.<\/li>\n<li>You <strong>must<\/strong> change <code>ea-php54<\/code> to the version on which your system currently runs. For example, if your system runs on PHP version 5.5 or 5.6, change <code>ea-php54<\/code> to <code>ea-php55<\/code> or <code>ea-php56<\/code>.<\/li>\n<\/ul><\/div>\n<\/div>\n<h3 id=\"required-files\">Required files<\/h3>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>Use the required file <code>\/var\/cpanel\/userdata\/[user]\/[domain].php-fpm.yaml<\/code> <strong>only<\/strong> if you wish to run PHP-FPM.<\/p>\n<\/p><\/div>\n<\/div>\n<ul>\n<li><code>\/var\/cpanel\/userdata\/[user]\/[domain].php-fpm.yaml<\/code> \u2014 This file controls a specific domain\u2019s pool. The system uses the built-in default values and <code>system_pool_defaults<\/code> values to generate the <code>[domain].conf<\/code> file.<\/li>\n<\/ul>\n<h3 id=\"optional-files\">Optional files<\/h3>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>Use the following optional files <strong>only<\/strong> if you wish to change the default parameters. <strong>All<\/strong> domain pools use these defaults unless a <code>.yaml<\/code> file overrides them.<\/p>\n<\/p><\/div>\n<\/div>\n<ul>\n<li><code>\/var\/cpanel\/ApachePHPFPM\/system.yaml<\/code> \u2014 This file contains system level settings. The system also uses this file to generate the <code>\/opt\/cpanel\/ea-php5?\/root\/etc\/php-fpm.conf<\/code> file, where the <code>?<\/code> indicates that the system uses this file to generate all of the PHP versions in the <code>php-fpm.conf<\/code> file.<\/li>\n<li><code>\/var\/cpanel\/ApachePHPFPM\/system_pool_defaults.yaml<\/code> \u2014 The system uses this file to generate each domain\u2019s pool and configure each user\u2019s pool.\n<div class=\"callout callout-warning\">\n<div class=\"callout-heading\">Important:<\/div>\n<div class=\"callout-content\">\n<p>If you edit a user\u2019s pool in WHM\u2019s <em>MultiPHP Manager<\/em> interface (<em>WHM &gt;&gt; Home &gt;&gt; Software &gt;&gt; MultiPHP Manager<\/em>), the system no longer applies the system default settings to that user.<\/p>\n<\/p><\/div>\n<\/div>\n<\/li>\n<\/ul>\n<h2 id=\"restore-php-to-your-system\">Restore PHP to your system<\/h2>\n<p>The system <strong>cannot<\/strong> remove configurations or other related files when you manually remove RPMs. If you manually remove RPMs, you could remove dependencies that your hosted websites require.<\/p>\n<div class=\"callout callout-danger\">\n<div class=\"callout-heading\">Warning:<\/div>\n<div class=\"callout-content\">\n<p>We do <strong>not<\/strong> recommend that you perform <code>yum remove<\/code> operations with any <code>ea-php<\/code> RPMs. If you remove PHP from your system while any of your hosted websites still use it, those websites will display errors. In addition, Apache could fail to display the website entirely. Before you perform a <code>yum remove<\/code> operation, confirm that none of your hosted websites use the PHP version that you wish to remove with WHM\u2019s <em>MultiPHP Manager<\/em> interface (<em>WHM &gt;&gt; Home &gt;&gt; Software &gt;&gt; MultiPHP Manager<\/em>).<\/p>\n<\/p><\/div>\n<\/div>\n<p>To restore PHP versions to your system, run the following commands:<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"color:#a6e22e\">ea_install_profile<\/span> <span style=\"color:#f92672\">--<\/span><span style=\"color:#a6e22e\">install<\/span> <span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">etc<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">cpanel<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">ea4<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">profiles<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">cpanel<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#66d9ef\">default<\/span>.<span style=\"color:#a6e22e\">json<\/span>\n<span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">usr<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">local<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">cpanel<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">scripts<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">restartsrv<\/span> <span style=\"color:#a6e22e\">apache_php_fpm<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>If the above commands fail, contact your system administrator.<\/p>\n<\/p><\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview This document explains the following information about the PHP FastCGI Process Manager (PHP-FPM) daemon: The PHP-FPM filesystem layout. How the system implements PHP-FPM on your system. PHP-FPM provides an alternative FastCGI daemon for PHP that allows a website to handle significant loads. It allows a host to set specific amounts of resources to process &hellip;<\/p>\n","protected":false},"author":1,"featured_media":803,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/802"}],"collection":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/comments?post=802"}],"version-history":[{"count":0,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/802\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media\/803"}],"wp:attachment":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media?parent=802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/categories?post=802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/tags?post=802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}