Where Does The PHP Error Log Reside

I‘m running CentOS 5.x server with Apache 2.2 + PHP 5.x server. Can you tell me exact location for php error log file?

Generally, on all production web servers displaying error to end users via a web browser is turned off using php.ini file settings. Open /etc/php.ini file and find out line that read as follows:

error_log

OR use the grep command as follows:

grep error_log /etc/php.ini
grep ^error_log /etc/php.ini

grep error_log /etc/php.ini
grep ^error_log /etc/php.ini

Sample outputs:

error_log = /var/log/httpd/php_error_log

The error_log directive defines the name of the file where script errors should be logged. The file should be writable by the web server’s user. If the special value syslog is used, the errors are sent to the system logger instead. On Unix, this means syslogd and on Windows NT it means the event log. The system logger is not supported on Windows 95. If this directive is not set, errors are sent to the SAPI error logger. For example, it is an error log in Apache (/var/log/httpd/error_log file) or stderr in command line (CLI).

This line define exact location for each php instance. If error_log set to syslog, open /var/log/messages file to view log. For example if error_log is set to /var/log/apache/php.errors, type the following to display error log:
$ tail -f /var/log/apache/php.errors
$ grep something /var/log/apache/php.errors
$ vi /var/log/apache/php.errors

See also:

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.