We have a new documentation site for cPanel & WHM! You can find our new documentation site at docs.cpanel.net.

We will continue to maintain our API documentation on this server.

Page tree
Skip to end of metadata
Go to start of metadata

Introduction

This tutorial explains how to manage php.ini file directives when you enable PHP-FPM. For more information, read our PHP-FPM documentation.

Note:

  • In cPanel & WHM version 78 and later, you can edit php.ini directives at the domain and system level in WHM's MultiPHP Manager interface (WHM >> Home >> Software >> MultiPHP Manager).
  • In cPanel & WHM version 76 and later, PHP-FPM is enabled by default.

Manage php.ini directives


Confirm that PHP-FPM exists on all of your accounts.

To confirm that PHP-FPM exists, perform the following steps:

  1. Log in to WHM as the root user.
  2. Navigate to WHM's MultiPHP Manager interface (WHM >> Home >> Software >> MultiPHP Manager).
  3. In the domains table, locate the domain for which to manage php.ini settings.
  4. Under the PHP-FPM heading, confirm that the toggle is set to On.

Remember:

As of cPanel & WHM version 76, PHP-FPM is enabled by default.

 


 

Create a phpinfo file in the domain's document root.

You can use phpinfo files to view a domain's current PHP settings.

To create this file for the domain, perform the following steps:

  1. SSH in as the root user.

    Note:

    You can also use WHM's Terminal interface (WHM >> Home >> Server Configuration >> Terminal).

  2. Navigate to the domain's document root directory.
  3. Create a phpinfo.php file.
  4. With a text editor, add the following information to the file:

    <?php
    // Show all information, defaults to INFO_ALL
    phpinfo();
    ?>
  5. Make certain that you perform the following actions:
    • Set the file's user and group ownership to the cPanel account's username.
    • Set the file's permissions to 0644 permissions.

    To do this, run the following series of commands:

    Note:

    In this example, username represent's the user's username.

    chmod 0644 /home/username/public_html/phpinfo.php
    chown username.username /home/username/public_html/phpinfo.php
  6. To access the file in your web browser, navigate to https://example.com/phpinfo.php, where example.com is the domain. If PHP-FPM exists on the domain, the browser will display FPM/FastCGI as the ServerAPI key's value.

 


 

Review the domain's php.ini directives.

You can review php.ini directives in either of the following interfaces:

  • Review a domain's php.ini directives in cPanel's MultiPHP INI Editor interface (cPanel >> Home >> Software >> MultiPHP INI Editor).
  • Review the global php.ini directives in WHM's MultiPHP INI Editor interface (WHM >> Home  >> Software >> MultiPHP INI Editor).

The system sets the following php.ini directives by default:

php_admin_flag[allow_url_fopen] = on
php_admin_flag[log_errors] = on
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
php_admin_value[doc_root] = "/home/username/public_html"
php_admin_value[error_log] = /home/username/logs/domain_com.php.error.log
php_admin_value[short_open_tag] = on
php_value[error_reporting] = E_ALL & ~E_NOTICE

 


 

Modify php.ini directives

Select the tab for your preferred method:

To globally modify php.ini directives for each PHP version, use WHM's MultiPHP INI Editor interface (WHM >> Home >> Software >> MultiPHP INI Editor).

To only modify specific php.ini directives for domains with PHP-FPM:

  1. SSH in to the server.
  2. Create the /var/cpanel/ApachePHPFPM directory if it does not already exist.
  3. Create the /system_pool_defaults.yaml file.

  4. With a text editor, add your desired PHP-FPM pools. PHP-FPM pools let you configure websites and applications to run under their own users. For example:

    ---
    php_admin_value_memory_limit: { name: 'php_admin_value[memory_limit]', value: 120M }

    Note:

  5. Regenerate the PHP-FPM configuration files. To do this, run the following command:

    /usr/local/cpanel/scripts/php_fpm_config --rebuild
  6. Restart Apache and the PHP-FPM services. To do this, run the following commands:

    /usr/local/cpanel/scripts/restartsrv_apache_php_fpm
    /usr/local/cpanel/scripts/restartsrv_httpd

To globally modify a domain's php.ini directives for each PHP version, use cPanel's MultiPHP INI Editor interface (cPanel >> Home >> Software >> MultiPHP INI Editor).

To only modify specific php.ini directives for a domain:

  1. SSH in to the server.

  2. Create the /var/cpanel/userdata/username/domain.com.php-fpm.yaml file if it does not already exist.

    Note:

    In this example, username represents the cPanel user's username.

  3. With a text editor, add the directives that you want to modify to the file.
    For example, this file would disable the passthru and system directives:

    ---
    _is_present: 1
    php_admin_value_disable_functions: { name: 'php_admin_value[disable_functions]', value: passthru,system }

    This file would enable all directives:

    ---
    _is_present: 1
    php_admin_value_disable_functions: { name: 'php_admin_value[disable_functions]', value: none }

    Note:

    For a complete list of PHP-FPM user pool directives, read our Configuration Values of PHP-FPM documentation.

  4. Regenerate the PHP-FPM configuration files. To do this, run the following command:

    /usr/local/cpanel/scripts/php_fpm_config --rebuild
  5. Restart Apache and the PHP-FPM services. To do this, run the following commands:

    /usr/local/cpanel/scripts/restartsrv_apache_php_fpm
    /usr/local/cpanel/scripts/restartsrv_httpd

 

 

Additional documentation

There is no content with the specified labels

There is no content with the specified labels

There is no content with the specified labels