The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP-FPM PHP.ini configuration

Discussion in 'Workarounds and Optimization' started by Mark Croxton, Feb 28, 2017.

Tags:
  1. Mark Croxton

    Mark Croxton Member

    Joined:
    Feb 28, 2017
    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    1
    Location:
    Brighton, UK
    cPanel Access Level:
    Root Administrator
    As it's not exactly clear from the docs, I want to share my learnings with regards to configuring PHP.ini values when using PHP-FPM.

    The good news is that most values can be set using the MultiPHP INI Editor in WHM. Edits made here are reflected in the corresponding local.ini file for the chosen version of PHP:

    /opt/cpanel/ea-php[version]/root/etc/php.d/local.ini

    Infuriatingly though, some values will not change regardless of the values you enter here or directly in this file, most notably those relating to error reporting. This is because they are controlled by the .conf file for each PHP-FPM pool.

    These files are located at:
    /opt/cpanel/ea-php[version]/root/etc/php-fpm.d/[domain].conf

    Inside these files you will find a number of php.ini values like so:

    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/[account]/public_html"
    php_admin_value[error_log] = /home/[account]/logs/[domain].php.error.log
    php_admin_value[error_reporting] = E_ALL & ~E_NOTICE
    php_admin_value[short_open_tag] = on

    Unfortunately you cannot edit these files directly, as they are generated by cPanel so any changes may be overwritten.

    To change them you must edit the corresponding yaml template file, located here:
    /var/cpanel/userdata/[account]/[domain].php-fpm.yaml

    Inside these files you can set any of the pool directive values listed here:
    Configurations Values of PHP-FPM - Documentation - cPanel Documentation

    Use the form:

    pool_directive_key : value

    So for example, to disable notice, warning, strict and deprecated errors:

    php_admin_value_error_reporting: E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_DEPRECATED

    Finally, you will need to get cPanel to rebuild the config files and restart PHP-FPM. To do that run this command:

    /scripts/php_fpm_config --rebuild

    A word of warning: should you use WHM > MultiPHP Manager to change values for each pool, you will find that cPanel unhelpfully rebuilds the conf files without using your customised yaml templates. This has been reported as a bug to cPanel, hopefully they will fix it in a later release.

    Another oddity: it is not possible to change the value of error_reporting at runtime using the PHP function error_reporting() when using PHP-FPM 5.6.x. This DOES work in PHP 7.0 however. I don't know why.

    Finally, if anyone knows how to change the default values for each version of PHP, rather than having to edit for each domain, please let me know.
     
    did-vmonroig likes this.
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,171
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    This is handled via internal case EA-5615. You can monitor the Change Logs to see when the resolution is published:

    Change Logs - Change Logs - cPanel Documentation

    Could you let us know the full steps you took to change the value?

    The following document explains how this works:

    PHP-FPM Code and FileSystem Layout for EasyApache 4 - Documentation - cPanel Documentation

    Thank you.
     
  3. Mark Croxton

    Mark Croxton Member

    Joined:
    Feb 28, 2017
    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    1
    Location:
    Brighton, UK
    cPanel Access Level:
    Root Administrator

    Another oddity: it is not possible to change the value of error_reporting at runtime using the PHP function error_reporting() when using PHP-FPM 5.6.x. This DOES work in PHP 7.0 however. I don't know why.
    Could you let us know the full steps you took to change the value?

    Compile Apache (event mpm) + PHP-FPM 5.6 and 7.0 with EA4.
    Set an account to use PHP-FPM 5.6.
    Create a file test.php in the webroot of this account, and add this to it:

    error_reporting(0);
    phpinfo();

    Result: PHP info will report a non-zero value for error_reporting.

    Switch the account to PHP-FPM 7.0 and you will see error_reporting is set to 0 in PHP info.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,171
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Feel free to open a support ticket using the link in my signature so we can take a closer look at the affected system. You can post the ticket number here so we can update this thread with the outcome.

    Thank you.
     
  5. did-vmonroig

    did-vmonroig Active Member

    Joined:
    Feb 6, 2012
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    56
    cPanel Access Level:
    Root Administrator
    Any news about this? We still have YAML files reset every time.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,171
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    There's no update to report at this time, but I will continue to monitor the case and provide updates as they become available.

    Thank you.
     
    did-vmonroig likes this.
Loading...

Share This Page