Search code examples
phpapachelamperror-reportingerror-log

Can't get PHP errors to go to a log file (other than the Apache log)


On a Ubuntu web server [LAMP], I'm trying to get PHP errors to write into a php_error file, but no matter what I do, they keep going to the apache log.

Here's what I have tried/done:

  1. Edited the php.ini file:

    • error_reporting = E_ALL | E_STRICT
    • display_error = Off
    • log_errors = On
    • error_log = /var/log/php_errors.log
  2. Restarted Apache

  3. Checked the phpinfo() output to verify that the changes I made to the php.ini file took -- they did.

  4. After verifying that the errors were still going to the Apache log, I physically created the php_errors.log and tried again. Still going to the Apache log!

  5. Rebooted the web server! Still...!

Anybody have a solution?


Solution

  • It had to do with ownership. One or the other has worked [for reasons that are not clear to me]:

    chown www-data:www-data /var/log/php_error.log
    
    chown same-user-as-www-home:same-user-as-web-home /var/log/php_error.log
    

    Also, the following has made a difference:

    chmod 664 /var/log/php_error.log
    

    [as opposed to chmod 644...again for reasons that are not clear to me]