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

Introduction

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

Note:

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

Migrate your cPanel accounts


Confirm that PHP-FPM exists on all 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 for WHM 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. Log in to the server as the root user via SSH.

    Note:

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


  2. Navigate to the domain's document root.
  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, enter example.com/phpinfo.php to open the file. 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 below that corresponds to how you wish to configure php.ini directives:

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

To modify specific php.ini directives only for domains that use PHP-FPM, perform the following steps via the command line:

  1. Create the /var/cpanel/ApachePHPFPM directory, if it does not already exist.
  2. Create the /system_pool_defaults.yaml file.

  3. With a text editor, add your desired PHP-FPM pools. PHP-FPM pools allow you to configure different websites and applications to run under their own user. For example:

    Note:

    ---
    php_admin_value_memory_limit: { name: 'php_admin_value[memory_limit]', value: 120M }
  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

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 modify specific php.ini directives for a domain, perform the following steps via the command line:

  1. 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.

  2. With a text editor, add the directives that you want to modify to the file. For example:

    Note:

    • This example sets passthru,system as the value for the disable_functions directive.
    • For a complete list of PHP-FPM user pool directives, read our Configuration Values of PHP-FPM documentation.
    ---
    _is_present: 1
    php_admin_value_disable_functions: { name: 'php_admin_value[disable_functions]', value: passthru,system }
  3. Regenerate the PHP-FPM configuration files. To do this, run the following command:

    /usr/local/cpanel/scripts/php_fpm_config --rebuild
  4. 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