Changing PHP-FPM error_log location

rappie

Active Member
Oct 4, 2008
29
4
53
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?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,270
463
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:

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

Thank you.
 
Last edited by a moderator: