How to Manage Your php.ini Directives with PHP FPM
Last modified: February 21, 2024
Introduction
This tutorial explains how to manage your php.ini
file directives when you enable PHP-FPM. For more information, read our PHP-FPM documentation.
- You can edit the
php.ini
directives at the domain and system level in WHM’s MultiPHP Manager interface (WHM » Home » Software » MultiPHP Manager). - cPanel & WHM enables PHP-FPM by default.
Manage the 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 the
php.ini
settings. - Under the PHP-FPM heading, confirm that the toggle is set to On.
Create a phpinfo file in the domain’s document root.
You can use the 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:
1 2 3 4
<?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.Note:To do this, run the following series of commands:
Where `username` represent's the user's username.1 2
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:
|
|
Modify the php.ini directives
Modify the php.ini directives globally
To globally modify the 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:
- Connect to the server via SSH.
- 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:
1 2
--- 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 domain 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:
1 2
/usr/local/cpanel/scripts/restartsrv_apache_php_fpm /usr/local/cpanel/scripts/restartsrv_httpd
Modify the php.ini directives for an individual domain
To globally modify a domain’s php.ini
directives for each PHP version, use cPanel’s MultiPHP INI Editor Editor interface (cPanel » Home » Software » MultiPHP INI Editor).
To only modify specific php.ini
directives for a domain:
- Connect to the server via SSH.
- Create the
/var/cpanel/userdata/username/domain.com.php-fpm.yaml
file if it does not already exist.Note:In this example, the
username
respresents 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 the
passthru
and system directives:This file would enable all directives:1 2 3
--- _is_present: 1 php_admin_value_disable_functions: { name: 'php_admin_value[disable_functions]', value: passthru,system }
1 2 3
--- _is_present: 1 php_admin_value_disable_functions: { name: 'php_admin_value[disable_functions]', value: none }
Note:For a complete list of PHP-FPM domain 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
|
|