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:


OR use the grep command as follows:

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:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 9 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
9 comments… add one
  • Anthony Thyssen Apr 7, 2010 @ 5:27

    The problem with the default set-up on a larger multi-user linux server environment is that System log files are NOT readable by ordinary users. As such it is recommended that users add something like the following to their PHP scripts.

    ini_set(‘error_log’, ‘script_errors.log’)
    ini_set(‘log_errors’, ‘On’)
    ini_set(‘display_errors’, ‘Off’)

    Note the file “script_errors.log” may need a full path, and should be writeable by the Apache web server user. That is it should exist with permissions 701 (writeable by others)

  • Perfector Jun 15, 2010 @ 13:45

    What if I’m using lighttpd? Where will I be able to find php logs?

  • Boyko Jan 15, 2012 @ 16:52

    Hey, this helped me. Thanks much!

  • Jaime Lumsden Kelly Aug 21, 2014 @ 10:42

    The problem with these types of posts is that everyone assumes that the reader knows what you’re talking about at the point that your article starts. for example, you say: Open /etc/php.ini file

    I wish someone would write an article that said what that is and where to find it!

    • Casey Arnold Jul 9, 2015 @ 20:05

      You can easily find your PHP configuration file by running “php –ini“, the output will list all configuration files the PHP compiler is using.

    • undersound Nov 20, 2015 @ 9:52

      While you’re at it also ask if the author makes you a sandwich every morning.

  • Mike Dec 16, 2015 @ 8:29

    So, if you don’t know the exact location and you want to know the error_log configuration value, do:

    php -ini | grep error_log

  • Jabari Hunt May 24, 2016 @ 14:27

    You can always make a phpinfo() file and see where it’s stored.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum