Bobcares

wesupport

CLIENT AREACall Us 1-800-383-5193
Bobcares

wesupport

Call Us 1-800-383-5193
Bobcares

wesupport

Call Us 1-800-383-5193

Need help?

Our experts have had an average response time of 11.7 minutes in August 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Manage php.ini directives with PHP FPM – How we do it

by | Dec 30, 2020

Need help to manage php.ini directives with PHP FPM? We can help you.

Here, at Bobcares, we assist several of our customers with this query as part of our Server Management Services.

Today, let us see an effective method our techs suggest in order to manage php.ini directives with PHP FPM.

 

php.ini directives and PHP FPM

If we want to modify php.ini directives at the domain and system level, we can perform this from WHM’s MultiPHP Manager interface. This is applicable if cPanel & WHM version is 78 or later.

To do that, go to, WHM >> Home >> Software >> MultiPHP Manager

Manage php.ini directives with PHP FPM

However, changes made through the MultiPHP Manager interface will not reflect, if we enable PHP FPM.

PHP-FPM (FastCGI Process Manager) is fast. If we want to be able to handle lots of requests then we should at least test out PHP-FPM’s performance.

We can think of PHP-FPM as a more advanced/refined version of FCGI, or FastCGI. If we enable PHP FPM, then PHP FPM user pool default values replace the MultiPHP as well as php.ini values.

On the other hand, in cPanel & WHM version 76 and later, PHP-FPM is enabled by default.

 

How to manage php.ini directives

Moving ahead, we will see an effective method our Support Engineers finds the best fit in order to manage php.ini directives with PHP FPM.

 

Step 1: Confirm whether PHP-FPM exists on all accounts.

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

  1. Log in to WHM as the root user.
  2. Then 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. Finally, under the PHP-FPM heading, confirm that the toggle is set to On.

 

Step 2: Create a phpinfo file in the domain’s document root.

We use phpinfo files to view a domain’s current PHP settings. To create this file for the domain, we perform the following steps:

  1. SSH in as the root user.
    Similarly, we can also use WHM’s Terminal interface (WHM >> Home >> Server Configuration >> Terminal).
  2. Then navigate to the domain’s document root directory.
  3. Now create a phpinfo.php file.
  4. Then with a text editor, add the following information to the file:
    <?php
    // Show all information, defaults to INFO_ALL
    phpinfo();
    ?>
  5. We make certain that we perform the following actions:
    a) Set the file’s user and group ownership to the cPanel account’s username:

    chown username.username /home/username/public_html/phpinfo.php

    b) Set the file’s permissions to 0644 permissions:

    chmod 0644 /home/username/public_html/phpinfo.php

    Where username represents the user’s username.

  6. To access the file in our 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.

 

Step 3: Review the domain’s php.ini directives.

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

  • Review a domain’s php.ini directives in cPanel’s MultiPHP Manager interface (cPanel >> Home >> Software >> MultiPHP INI Editor).
  • Review the global php.ini directives in WHM’s MultiPHP Manager 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

 

Step 4: Modify php.ini directives

Step 4. (a): Modify php.ini directives globally

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

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

  1. Initially, we connect to the server via SSH.
  2. Then we create the /var/cpanel/ApachePHPFPM directory if it does not already exist.
  3. Here, create the /system_pool_defaults.yaml file.
  4. With a text editor, we add PHP-FPM pools. PHP-FPM pools 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 }

    This example sets a memory limit of 120 MB.

  5. Then we regenerate the PHP-FPM configuration files. To do this, we run the following command:
    /usr/local/cpanel/scripts/php_fpm_config –rebuild
  6. Finally, restart Apache and the PHP-FPM services. To do this, we run the following commands:
    /usr/local/cpanel/scripts/restartsrv_apache_php_fpm
    /usr/local/cpanel/scripts/restartsrv_httpd

Step 4. (b): Modify php.ini directives for an individual domain

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

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

  1. First, we connect to the server via SSH.
  2. Then we create the /var/cpanel/userdata/username/domain.com.php-fpm.yaml file if it does not already exist. In this example, the username represents the cPanel user’s username.
  3. With a text editor, we add the directives that we 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 }
  4. Regenerate the PHP-FPM configuration files. To do this, we run the following command:
    /usr/local/cpanel/scripts/php_fpm_config –rebuild
  5. Finally, restart Apache and the PHP-FPM services. To do this, we run the following commands:
    /usr/local/cpanel/scripts/restartsrv_apache_php_fpm
    /usr/local/cpanel/scripts/restartsrv_httpd

[Couldn’t manage the directives? We can help you!]

 

Conclusion

To conclude, if we have a busy site and want to be able to handle lots of requests then we should test out PHP-FPM’s performance. Today we saw how our Support Engineers go about with this query.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *