PHP error log in same directory as script

rappie

Active Member
Oct 4, 2008
29
4
53
Amsterdam
How can I let PHP create an error_log file in the same directory as the script that throws the error?

I am running CGI php handler. Current ini setting error_log value is error_log. (error_log = error_log)
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,213
363
Hello @rappie,

This should happen by default if you are using CGI as the PHP handler. Can you browse to WHM >> MultiPHP Manager and confirm if PHP-FPM is enabled for the domain you are testing with?

Thank you.
 

rappie

Active Member
Oct 4, 2008
29
4
53
Amsterdam
@cPanelMichael thank you. I always thought having the error_log file in the same directory as the script that throws error was default behavior when using CGI as the PHP handler as well. However this doesn't seem to the case on my install. The PHP-FPM option is turned off for all domains.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,213
363
Hello @rappie,

I created a test account/domain on a server running cPanel & WHM version 80.0.20 and selected CGI as the PHP handler. Upon generating a PHP error in a test PHP script, the error_log file was generated in the document root of the PHP script.

Could you open a support ticket so we can take a closer look at your system? You can post the ticket number here once it's opened and I'll link this thread to it.

Thank you.
 

rappie

Active Member
Oct 4, 2008
29
4
53
Amsterdam
Hi @cPanelMichael

Thank you. I think I have managend to narrow it down to the MPM. Only when the prefork MPM is used a error_log file is created in the same directory as the script that throws the error. Is this right? Or should this also work when any of the other MPM's are used?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,213
363
Hello @rappie,

Upon testing with the Worker and Event MPMs, I can confirm you are correct. The Prefork MPM is required for direct logging to the individual PHP error_log file under the website's document root directory. With the Worker and Event MPMs, the PHP errors are logged directly to the Apache error log (/usr/local/apache/logs/error_log).

You can read more about each MPM at:

Multi-Processing Modules - MPMs - EasyApache 4 - cPanel Documentation

Thank you.