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:
- Log in to WHM as the
root
user. - Navigate to WHM's MultiPHP Manager interface (WHM >> Home >> Software >> MultiPHP Manager).
- In the domains table, locate the domain for which to manage
php.ini
settings. - 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:
SSH in as the
root
user.Note:
You can also use WHM's Terminal interface (WHM >> Home >> Server Configuration >> Terminal).
- Navigate to the domain's document root directory.
- Create a
phpinfo.php
file. With a text editor, add the following information to the file:
<?php // Show all information, defaults to INFO_ALL phpinfo(); ?>
- 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
To access the file in your web browser, navigate to
https://example.com/phpinfo.php
, whereexample.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:
- SSH in to the server.
- Create the
/var/cpanel/ApachePHPFPM
directory if it does not already exist. Create the
/system_pool_defaults.yaml
file.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:
- This example sets a memory limit of 120 MB.
- For a complete list of PHP-FPM user pool directives, read our Configuration Values of PHP-FPM documentation.
Regenerate the PHP-FPM configuration files. To do this, run the following command:
/usr/local/cpanel/scripts/php_fpm_config --rebuild
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:
SSH in to the server.
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.With a text editor, add the directives that you want to modify to the file.
For example, this file would disable thepassthru
andsystem
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.
Regenerate the PHP-FPM configuration files. To do this, run the following command:
/usr/local/cpanel/scripts/php_fpm_config --rebuild
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