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: