Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have Fedora 16 with nginx and php-fpm. Everything is working very good. All logs with php notice,warnig error etc. are in /var/log/php-fpm/www-error.log. Is there a way to configure php-fpm to write errors in proper log files configured as error logs for nginx ? So I want to logs php errors per virtualhost not in one global file. (like in apache and php).

share|improve this question

1 Answer 1

up vote 7 down vote accepted

The PHP-FPM directive: catch_workers_output = yes will cause errors PHP sends to stdout/stderr to be sent back to nginx, and they will be logged.

In PHP 5.2.4 and newer, the directive display_errors is no longer a boolean, but will accept 'stderr' as an option. This should cause all of the errors to go back to nginx, and be logged per vhost

So in your PHP-FPM config: php_admin_value[display_errors] = 'stderr'

Your other option is the directive: php_admin_value[error_log] = /var/log/fpm-php.www.log

which is what you are likely using now. the php-fpm.conf supports some variables, like $pool (which for you, will likely return 'www').

If you have more than 1 pool, you can easily log them separately.

From a quick browse through the source code, it looks like $pool is the only such variable though.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.