×ðÁú¿­Ê±¹ÙÍøµÇ¼

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µÄÈÕÖ¾ÔõôÇиîµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Á¢³¡£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ