Child pages
  • WHM API 1 Functions - php_fpm_config_set
Skip to end of metadata
Go to start of metadata

Description

This function configures the PHP INI directives and pool options for a system's or domain's PHP-FPM configuration.


Warning:

We strongly 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.

Important:

In cPanel & WHM version 76 and later, when you disable the WebServer role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples


 Raw HTTP Request

System configuration

GET /cpsess##########/json-api/php_fpm_config_set HTTP/1.1
Host: example.com:2087
Cookie: ###################################
Content-Type: application/json
Content-Length: 98
 
{
    "domain": "",
    "validate_only" : false,
    "config": [
        {
            "trinary_admin_value": 1,
            "base_flag_name": "error_reporting",
            "value": "E_ALL & ~E_NOTICE"
        },
        {
            "trinary_admin_value": 0,
            "base_flag_name": "pm_max_children",
            "value": "5"
        }
    ]
}

Domain configuration

GET /cpsess##########/json-api/php_fpm_config_set HTTP/1.1
Host: example.com:2087
Cookie: ###################################
Content-Type: application/json
Content-Length: 98
 
{
    "domain": "example.com",
    "validate_only" : false,
    "config": [
        {
            "trinary_admin_value": 1,
            "base_flag_name": "error_reporting",
            "value": "E_ALL & ~E_NOTICE"
        },
        {
            "trinary_admin_value": 0,
            "base_flag_name": "pm_max_children",
            "value": "10"
        }
    ]
}
 JSON API

System configuration

URL
https://hostname.example.com:2087/cpsess##########/json-api/php_fpm_config_set
MethodGET
Content-Typeapplication/json
Request body
{
    "domain": "",
    "validate_only" : false,
    "config": [
        {
            "trinary_admin_value": 1,
            "base_flag_name": "error_reporting",
            "value": "E_ALL & ~E_NOTICE"
        },
        {
            "trinary_admin_value": 0,
            "base_flag_name": "pm_max_children",
            "value": "5"
        }
    ]
}

Domain configuration

URL
https://hostname.example.com:2087/cpsess##########/json-api/php_fpm_config_set
MethodGET
Content-Typeapplication/json
Request body
{
    "domain": "example.com",
    "validate_only" : false,
    "config": [
        {
            "trinary_admin_value": 1,
            "base_flag_name": "error_reporting",
            "value": "E_ALL & ~E_NOTICE"
        },
        {
            "trinary_admin_value": 0,
            "base_flag_name": "pm_max_children",
            "value": "10"
        }
    ]
}
 Command Line


Notes:

  • The format for this command line example differs from our standard format because the function only accepts a single JSON structure.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command. 

System configuration

echo '{"domain": "", "validate_only" : false, "config": [{"trinary_admin_value": 1, "base_flag_name": "error_reporting", "value": "E_ALL & ~E_NOTICE"}, {"trinary_admin_value": 0, "base_flag_name": "pm_max_children", "value": "10"}]}' | whmapi1 --input=json --output=json php_fpm_config_set

 Domain configuration

echo '{"domain": "example.com", "validate_only" : false, "config": [{"trinary_admin_value": 1, "base_flag_name": "error_reporting", "value": "E_ALL & ~E_NOTICE"}, {"trinary_admin_value": 0, "base_flag_name": "pm_max_children", "value": "10"}]}' | whmapi1 --input=json --output=json php_fpm_config_set


Notes:

  • You must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)

System configuration

{
   "metadata":{
      "result":1,
      "version":1,
      "command":"php_fpm_config_set",
      "reason":"OK"
   }
}

Domain configuration

{
   "metadata":{
      "result":1,
      "version":1,
      "command":"php_fpm_config_set",
      "reason":"OK"
   }
}


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

Parameters

Note:

You can only call this function as a JSON request.

ParameterTypeDescriptionPossible valuesExample

JSON

An unnamed JSON string that encodes a hash of values.

A valid JSON string that contains the domain, validate_only, and config parameters.

 

domain

string

A blank value or domain name whose PHP-FPM configuration you wish to set.

The function accepts this parameter in the unnamed JSON string.

Note:

This parameter defaults to a blank value.

  • A valid domain that resides on the local server — Sets a domain's PHP-FPM configuration.
  • A blank value — Sets the system's PHP-FPM configuration information.
example.com

validate_only

string

Whether the function request is for validation or to update the settings.

The function accepts this parameter in the unnamed JSON string.

Note:

This parameter defaults to false.

  • true — Validation only.
  • false — Not for validation (saves the configuration settings).
false

config

array of hashes

Required

A hash that contains the PHP-FPM configuration values.

The function accepts this parameter in the unnamed JSON string.

Each hash contains the base_flag_name, trinary_admin_value, and value parameters.

 

base_flag_name

string

Required

A PHP INI directive or PHP-FPM pool option name.

The function accepts this parameter in the config array of hashes.



PHP INI directives

  • allow_url_fopen — The PHP configuration will treat URLs as files.

  • disable_functions — Lists the functions that the system will disable.

  • doc_root — The PHP pages' document root.

  • error_log — The error log file.

  • error_reporting — The errors that the system reports on.
  • log_errors — Whether the system will log errors.
  • short_open_tag — Whether the system recognizes code between the <? and ?> tags as a PHP source.

Pool options

  • pm_max_children — The maximum number of process pools that the PHP-FPM Master Process will generate to handle requests.
  • pm_max_requests — The maximum number of requests that the process pools can receive.
  • pm_process_idle_timeout — The amount of time, in seconds, that a pool process will wait for a request.

pm_max_children

trinary_admin_value

integer

Required

Whether the PHP value is a PHP INI directive value (php_value), a PHP INI ADMIN value (php_admin_value), or a PHP-FPM pool option (pm_*).

The function accepts this parameter in the config array of hashes.

  • 0 — A PHP-FPM-specific value (pool options).
  • 1 — A PHP INI ADMIN directive. A cPanel account user cannot override this directive.
  • 2 — A PHP INI directive. A cPanel account user can override this directive.
0

value

string

Required

The base_flag_name's value.

The function accepts this parameter in the config array of hashes.

A string value.5

Returns

This function only returns metadata.