Implement the configuration method for logging PHP error logs when using PHP-FPM in Nginx _nginx

Source: Internet
Author: User
Tags fpm php error php error log

Nginx and Apache are not the same, in Apache can directly specify the error log php, so that in the PHP implementation of the error message directly into the PHP error log, you can easily query.

In Nginx, things have become like this: Nginx only access to the page to make access log. There will be no error log information for PHP. Nginx to the PHP request to the PHP-FPM fastcgi process to deal with, the default php-fpm will only output PHP-FPM error message, in PHP-FPM errors log also can not see the errorlog of PHP.

The reason is that PHP-FPM's profile php-fpm.conf The default is to turn off the error output of the worker process and redirect them directly to/dev/null, so we nginx the error log in the And PHP-FPM's errorlog don't see PHP's error log.

So we have to do the following settings to see Nginx under the PHP-FPM does not log the PHP error logging method:

1, modify the configuration in the php-fpm.conf , if not please add:

Copy Code code as follows:

[Global]
; note:the default Prefix Is/usr/local/php/var
Error_log = Log/php_error_log
[WWW]
Catch_workers_output = yes

2. Modify the configuration in PHP.ini, no increase:
Copy Code code as follows:

Log_errors = On
Error_log = "/usr/local/php/var/log/error_log"
Error_reporting=e_all&~e_notice

3. Restart PHP-FPM

When PHP executes an error, it sees the error log in "/usr/local/lnmp/php/var/log/php_error_log"

If it appears:

Copy Code code as follows:

[root@localhost etc]# Service php-fpm restart
Gracefully shutting down php-fpm. Done
Starting PHP-FPM [17-apr-2014 18:40:52] ERROR: [/usr/local/php/etc/php-fpm.conf:5] Unknown entry ' Catch_workers_
[17-apr-2014 18:40:52] error:failed to load configuration file '/usr/local/php/etc/php-fpm.conf '
[17-apr-2014 18:40:52] ERROR:FPM initialization failed
Failed

Then, in the first step, carefully put the configuration write to the corresponding group, otherwise appear above:

Copy Code code as follows:
ERROR: [/usr/local/php/etc/php-fpm.conf:5] Unknown entry ' catch_workers_output '

Finally look at the effect:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.