Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

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.

Changing PHP-FPM error_log location

Discussion in 'EasyApache' started by rappie, Feb 5, 2018.

Tags:
  1. rappie

    rappie Member

    Joined:
    Oct 4, 2008
    Messages:
    16
    Likes Received:
    2
    Trophy Points:
    53
    Location:
    Amsterdam
    I switched to using PHP-FPM as the default PHP handler for my servers. Works great!

    However, previously when using the default CGI handler, PHP error logs resided in the same directory as the PHP file that created the error. This was a very useful setup to me. With PHP-FPM the default error log location is at: /home/username/logs/domain_tld.php.error.log

    I'd like to change this so that error logs are created again in the same directory as the PHP file that caused the error.

    This seems a bit harder to achieve than I anticipated. I thought all I had to do is change the PHP-FPM configuration so that error log location is set to simply a the file name, without any slashes.

    I've added the following line blow to /var/cpanel/userdata/user/domain.php_fpm.yaml file and ran /usr/local/cpanel/scripts/php_fpm_config --rebuild.

    php_admin_value_error_log: { name: 'php_admin_value[error_log]', value: "error_log" }

    This successfully changed the error log value in the PHP configuration to error_log. Unfortunately however still no error_log file is created in the same directory as the PHP file that caused the error. Also errors aren't logged to the /home/username/logs/domain_tld.php.error.log location.

    So ... what am I missing? How do get a error log files created in the same directory as the PHP file that caused the error?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    42,715
    Likes Received:
    1,705
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    As I understand, you'd need to define a specific path. EX:

    Code:
    # cat /var/cpanel/userdata/username/domain.com.php-fpm.yaml
    ---
    _is_present: 1
    php_admin_value_error_log: { name: 'php_admin_value[error_log]', value: /home/username/public_html/error_log }
    As far as logging to individual error_log files in specific directories, you could try customizing a path with variables such as "[% documentroot %]" that we document at:

    Configurations Values of PHP-FPM - Version 68 Documentation - cPanel Documentation

    Thank you.
     
Loading...

Share This Page