Need Assistance?

In only two hours, with an average response time of 15 minutes, our expert will have your problem sorted out.

Server Trouble?

For a single, all-inclusive fee, we guarantee the continuous reliability, safety, and blazing speed of your servers.

How to Manage PHP.ini Directives with PHP FPM on a cPanel Server

Manage PHP.ini Directives with PHP FPM on cpanel can be useful for altering PHP configurations to specific application requirements. When using PHP-FPM alongside cPanel, the process becomes more streamlined and efficient.PHP-FPM (FastCGI Process Manager) significantly elevates PHP performance and provides more granular control over PHP settings. This blog post will take you through the steps for managing php.ini directives on a cPanel server using PHP-FPM.

Prerequisites

  1. A cPanel account with root access.
  2. PHP-FPM enabled on your server.
  3. Basic knowledge of how to use the cPanel interface

1. Enabling PHP-FPM in cPanel

Before managing php.ini directives, ensure PHP-FPM is enabled for your domain:

i. For this, First Log in to WHM 

ii. Then, Navigate to MultiPHP Manager and select User Domain settings.

iii. In the domain section, Select your domain and check whether “PHP-FPM” is enabled for the domain, if not then enable it.

2. php.ini File

It is always important to understand the current PHP configuration. You can find the existing php.ini file by creating a PHP info page.

Now, Create a file named phpinfo.php in your web root directory. Here I am using the root directory as: /home/testdomain.com/public_html/

#cd /home/testdomain.com/public_html/
# vim phpinfo.php

Add the following content to the file:

<?php

phpinfo();

?>

After changing the necessary file permissions, Access this file via your web browser (e.g., http://testdomain.com/phpinfo.php).

In the page, Verify that PHP_FPM is active or not.

3. Review and Modify php.ini Directives

You can review the domain’s php.ini directives in cPanel’s MultiPHP INI Editor interface (cPanel » Home » Software » MultiPHP INI Editor).

In WHM, you can review this in (WHM » Home » Software » MultiPHP INI Editor). You can find the system set default php.ini directive there.

For Global Modifications:

First, SSH into your server.

And then look for /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml. If it does not already exist, create it.

To modify the.yaml file, use the following command:

#vim /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml

Add the desired PHP-FPM pools and directives. for example you can set the memory limit of 120 MB by adding the following:

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

For Modifying specific php.ini directives for a domain, 

Create the file /var/cpanel/userdata/username/testdomain.com.php-fpm.yaml, then edit it with a text editor to add the directives you want to modify.

for example, to disable the passthru and system directives, use:

#vim /var/cpanel/userdata/username/testdomain.com.php-fpm.yaml
_is_present: 1
php_admin_value_disable_functions: { name: 'php_admin_value[disable_functions]', value: passthru,system }

To enable all the directives, using the following:

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

4. Regenerate the configuration and restart the services

After the modifications has been made, Regenerate the php-fpm configuration: 

#/usr/local/cpanel/scripts/php_fpm_config --rebuild

Restart the apache and php-fpm services for the changes to take effect:

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

By following these steps, you can effectively manage your PHP settings, ensuring optimised performance.

If you have any questions or need personalized assistance with “How to Manage PHP.ini Directives with PHP FPM on a cPanel Server” , don’t hesitate to reach out Skynats.

Liked!! Share the post.

Get Support right now!

Start server management with our 24x7 monitoring and active support team

Can't get what you are looking for?

Available 24x7 for emergency support.