nginxµÄÈÕÖ¾ÔõôÇиî
ÎÊÌ⣺ÔõÑùÔÚ nginx ÖÐÇиîÈÕÖ¾Îļþ£¿°ì·¨£ºÔÚ nginx ÉèÖÃÖÐÆôÓÃÈÕÖ¾Çиָ¶¨ÈÕ־·¾¶ºÍÃûÌ᣽¨ÉèÈÕÖ¾´æ´¢Ä¿Â¼¡£ÉèÖà cron ×÷Òµ°´ÆÚÇиîÈÕÖ¾Îļþ¡£ÑéÖ¤ÈÕÖ¾ÇиîÊÇ·ñ°´Ô¤ÆÚÊÂÇé¡£
Nginx ÈÕÖ¾Çиî
Nginx ÈÕÖ¾ÇиîÊÇÒ»¸öÖ÷ÒªµÄÀú³Ì£¬¿É×ÊÖúÖÎÀíºÍά»¤ÍøÕ¾ÈÕÖ¾Îļþ¡£ÒÔÏÂÊÇÔÚ Nginx ÖÐÇиîÈÕÖ¾ÎļþµÄ°ì·¨£º
1. ÔÚ Nginx ÉèÖÃÎļþÖÐÆôÓÃÈÕÖ¾Çиî
ÔÚ Nginx ÉèÖÃÎļþÖУ¨Í¨³£Î»ÓÚ /etc/nginx/nginx.conf£©£¬Ìí¼ÓÒÔÏÂÖ¸Á
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; access_log /var/log/nginx/access.log.1 main daily rotate=4;
µÇ¼ºó¸´ÖÆ
access_log Ö¸ÁîÖ¸¶¨ÈÕÖ¾ÎļþµÄ·¾¶ºÍÃûÌá£
rotate=4 ²ÎÊýÖ¸¶¨Òª±£´æ 4 ¸öÐýתÈÕÖ¾Îļþ¡£
2. ½¨ÉèÈÕ־Ŀ¼
È·±£Òѽ¨ÉèÓÃÓÚ´æ´¢ÈÕÖ¾ÎļþµÄĿ¼¡£ÔÚÉÏÃæµÄʾÀýÖУ¬´ËĿ¼ÊÇ /var/log/nginx¡£
3. ÉèÖÃÈÕÖ¾Çиî cron ×÷Òµ
½¨Éè cron ×÷ÒµÒÔ°´ÆÚÇиîÈÕÖ¾Îļþ¡£ÀýÈ磺
0 0 * * * /usr/sbin/logrotate /etc/logrotate.d/nginx
µÇ¼ºó¸´ÖÆ
´Ë×÷Òµ½«ÌìÌìÆÆÏþ 0 µãÔËÐÐÈÕÖ¾Çиî¾ç±¾¡£
4. ÑéÖ¤ÈÕÖ¾Çиî
ÖØмÓÔØ Nginx ÉèÖò¢¼ì²éÈÕÖ¾ÇиîÊÇ·ñÕýÔÚ°´Ô¤ÆÚÊÂÇ飺
nginx -s reload tail -n 4 /var/log/nginx/access.log tail -n 4 /var/log/nginx/access.log.1
µÇ¼ºó¸´ÖÆ
ÄúÓ¦¸ÃÄÜ¿´µ½ÈÕÖ¾ÎļþÒÑ׼ʱ¼äÇи
ÒÔÉϾÍÊÇnginxµÄÈÕÖ¾ÔõôÇиîµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡