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).

up vote 14 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.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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