nginx?errorÈÕÖ¾ÔõôÕûÀí
¹ýʧÈÕ־λÓÚ /var/log/nginx£¨linux£©»ò /usr/local/var/log/nginx£¨macos£©£¬Ê¹ÓÃÏÂÁîÐÐÕûÀí°ì·¨£º1. ±¸·ÝÔÈÕÖ¾£»2. ½¨Éè¿ÕÎļþ×÷ΪÐÂÈÕÖ¾£»3. ÖØÆô nginx ЧÀÍ¡£Ò²¿ÉʹÓõÚÈý·½¹¤¾ß£¨Èç logrotate£©»òÉèÖÃ×Ô¶¯ÕûÀí¡£
ÔõÑùÕûÀí Nginx ¹ýʧÈÕÖ¾
Ò»¡¢ÕÒµ½¹ýʧÈÕÖ¾Îļþ
¹ýʧÈÕ־ͨ³£Î»ÓÚÒÔÏ·¾¶£º
/var/log/nginx£¨Linux£©
/usr/local/var/log/nginx£¨macOS£©
¶þ¡¢¼ì²éÎļþ¾Þϸ
¼ì²é¹ýʧÈÕÖ¾ÎļþµÄÄ¿½ñ¾Þϸ£¬ÒÔÈ·¶¨ÊÇ·ñÐèÒªÕûÀí£º
ls -lh /var/log/nginx/error.log
µÇ¼ºó¸´ÖÆ
Èý¡¢Ê¹ÓÃÏÂÁîÐÐÕûÀí
°´ÒÔÏÂ˳ÐòÖ´ÐÐÏÂÁîÕûÀí¹ýʧÈÕÖ¾£º
±¸·ÝÔÓÐÈÕÖ¾Îļþ£º
mv /var/log/nginx/error.log /var/log/nginx/error.log.bak
µÇ¼ºó¸´ÖÆ
½¨ÉèÒ»¸ö¿ÕÎļþ×÷ΪеĹýʧÈÕÖ¾£º
touch /var/log/nginx/error.log
µÇ¼ºó¸´ÖÆ
ÖØÐÂÆô¶¯ Nginx ЧÀÍ£º
nginx -s reload
µÇ¼ºó¸´ÖÆ
ËÄ¡¢Ê¹ÓõÚÈý·½¹¤¾ß
³ýÁËʹÓÃÏÂÁîÐУ¬Ä㻹¿ÉÒÔʹÓõÚÈý·½¹¤¾ßÀ´ÕûÀí Nginx ¹ýʧÈÕÖ¾£¬ÀýÈ磺
logrotate£ºÕâÊÇÒ»¸öÈÕÖ¾ÖÎÀí¹¤¾ß£¬¿ÉÒÔ×Ô¶¯ÕûÀíºÍÂÖ»»ÈÕÖ¾Îļþ¡£
fail2ban£ºÕâÊÇÒ»¸öÈëÇÖ¼ì²âºÍÔ¤·Àϵͳ£¬Ëü¿ÉÒÔ»ùÓÚ¹ýʧÈÕÖ¾ÆÊÎö¿ÉÒÉÔ˶¯²¢×èÖ¹¹¥»÷¡£
Îå¡¢×Ô¶¯ÕûÀí
¹ØÓÚƵÈÔ±¬·¢¹ýʧÈÕÖ¾µÄ¸ßÁ÷Á¿ÍøÕ¾£¬¿ÉÒÔÉèÖà Nginx ×Ô¶¯ÕûÀí¾ÉµÄ¹ýʧÈÕÖ¾£º
·¿ª /etc/logrotate.d/nginx ÉèÖÃÎļþ¡£
Ìí¼ÓÒÔÏÂÐУº
/var/log/nginx/*.log { rotate 10 daily compress delaycompress missingok notifempty }
µÇ¼ºó¸´ÖÆ
´ËÉèÖý«±£´æÒÑÍù 10 ÌìµÄ¹ýʧÈÕÖ¾£¬²¢ÌìÌì×Ô¶¯Ñ¹ËõºÍɾ³ý¾ÉµÄÈÕÖ¾¡£
ÒÔÉϾÍÊÇnginx errorÈÕÖ¾ÔõôÕûÀíµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡