无法获取PHP错误转到日志文件(Apache日志除外)

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?

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]

Check the directory permissions for /var/log. Ensure that the user your Web service is running as has write permissions to that folder. Alternatively, create a subfolder (/var/log/phplogs?) and assign explicit permissions on that for the user in question then change the error_log value to be a file in that folder