Cpanel PHP-FPM error_log location
Hi,
So far, while I had CGI handler, PHP error logs resided in the same directory as the PHP file that created the error.
With PHP-FPM the default error log location is at: /home/username/logs/domain_tld.php.error.log
Is there a way to switch error log location so it will show in same directory where .php file which triggered error resides ?
So if file /home/username/public_html/tests/test.php triggered error I would like error log to be in /home/username/public_html/tests/
If a file in /home/username/public_html/school/questions/math.php triggers an error I would like error log to be placed in /home/username/public_html/school/questions/
Also I would like this to be enabled on all accounts with PHP-FPM enabled.
I am new at this so please explain it step-by-step.
Thanks !
-
Hey there! Could you try the workaround mentioned here and see if that gets you what you need?
https://support.cpanel.net/hc/en-us/community/posts/19121164499863
0 -
OK, I've changed /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml so it looks: --- 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: "\"[% documentroot %]/\"" php_admin_value_error_log: "[% documentroot %]/error.log" php_admin_value_short_open_tag: 'on' php_value_error_reporting: E_ALL & ~E_NOTICE pm_max_children: 500 pm_max_requests: 2000 pm_process_idle_timeout: 150 I've restarted both Apache and PHP-FPM service for Apache and nothing changed ? 0 -
Any help ? 0 -
As far as I understand it what you have isn't formatted correctly. This doesn't appear at all as it's noted in the documentation. This should be: php_admin_value_error_log: { name: 'php_value[error_log]', value: "[% homedir %]/logs/[% domain_tld %].php.error.log]" }
you can omit logs/ if you just want the data to go into the homedirectory of the user or if you do really want the logs to go into the document root it would be:php_admin_value_error_log: {name: 'php_value[error_log]', value: "[% documentroot %].php.error.log]"}
and any double quotes must be escaped as noted in the "important" section at the top: [QUOTE] Important: To avoid directive configuration errors, you must follow these syntax rules:- You must use single quotation marks ' ' at the beginning and end of strings with double quotation marks " ". The YAML parser automatically removes quotation marks from string values. This means that values that require double quotation marks must use single quotation marks before and after the double quotation marks to retain their value.
- You must use an escape character \ with any double quotation marks " " that you use inside of the string.
You can also use the config script to check your work and rebuild the configuration The php_fpm_config Script | cPanel & WHM Documentation This gives you the step by step workflow How to Manage Your php.ini Directives with PHP FPM | cPanel & WHM Documentation0 -
There needs to be a big red warning in cPanel saying "Please NOTE: PHP-FPM is going to screw up all of your error reporting"
0
Please sign in to leave a comment.
Comments
5 comments