2

When I am using apache/mod_php, the PHP error will appear in the apache's error log.

Now, I am using php-fpm with nginx via fcgi, is it possible to have the PHP error log in the nginx error log as well?

So far the only solution is to use external file as defined in the php.ini

error_log = /tmp/php_errors.log

But I want them in the nginx error log for the ease of maintenance.

Howard
  • 2,135
  • 13
  • 48
  • 72

1 Answers1

7

You need to make two changes:

  1. Unset PHP's error_log directive in php.ini. This will cause it to log to standard error, which nginx will then log to its own error log.
  2. Set catch_workers_output = yes in your php-fpm configuration php-fpm.conf, to ensure that the FPM SAPI doesn't discard standard error.
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972