{"id":41720,"date":"2024-10-02T05:51:43","date_gmt":"2024-10-01T21:51:43","guid":{"rendered":"https:\/\/server.hk\/cnblog\/41720\/"},"modified":"2024-10-02T05:51:44","modified_gmt":"2024-10-01T21:51:44","slug":"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8mod_log_config%e8%a8%ad%e5%ae%9aapache","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/41720\/","title":{"rendered":"Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528mod_log_config\u8a2d\u5b9aApache"},"content":{"rendered":"<h1 id=\"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8mod_log_config%e8%a8%ad%e5%ae%9aapache-YNDFHlqiNP\">Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528mod_log_config\u8a2d\u5b9aApache<\/h1>\n<p>Apache HTTP\u4f3a\u670d\u5668\u662f\u7576\u4eca\u6700\u6d41\u884c\u7684\u7db2\u9801\u4f3a\u670d\u5668\u4e4b\u4e00\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u7db2\u7ad9\u548c\u61c9\u7528\u7a0b\u5f0f\u4e2d\u3002\u5c0d\u65bc\u65b0\u624b\u4f86\u8aaa\uff0c\u4e86\u89e3\u5982\u4f55\u8a2d\u5b9aApache\u7684\u65e5\u8a8c\u8a18\u9304\u529f\u80fd\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u9019\u4e0d\u50c5\u6709\u52a9\u65bc\u76e3\u63a7\u4f3a\u670d\u5668\u7684\u904b\u884c\u72c0\u6cc1\uff0c\u9084\u80fd\u5e6b\u52a9\u6392\u67e5\u554f\u984c\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528Apache\u7684mod_log_config\u6a21\u7d44\u4f86\u8a2d\u5b9a\u65e5\u8a8c\u8a18\u9304\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afmod_log_config%ef%bc%9f-YNDFHlqiNP\">\u4ec0\u9ebc\u662fmod_log_config\uff1f<\/h2>\n<p>mod_log_config\u662fApache\u7684\u4e00\u500b\u6a21\u7d44\uff0c\u5c08\u9580\u7528\u65bc\u914d\u7f6e\u4f3a\u670d\u5668\u7684\u65e5\u8a8c\u8a18\u9304\u3002\u5b83\u5141\u8a31\u7528\u6236\u81ea\u5b9a\u7fa9\u65e5\u8a8c\u683c\u5f0f\uff0c\u4e26\u9078\u64c7\u8a18\u9304\u54ea\u4e9b\u4fe1\u606f\u3002\u9019\u5c0d\u65bc\u7db2\u7ad9\u7ba1\u7406\u54e1\u4f86\u8aaa\u662f\u975e\u5e38\u6709\u7528\u7684\uff0c\u56e0\u70ba\u5b83\u80fd\u5920\u63d0\u4f9b\u6709\u95dc\u8a2a\u554f\u8005\u884c\u70ba\u548c\u4f3a\u670d\u5668\u6027\u80fd\u7684\u8a73\u7d30\u6578\u64da\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9dapache%e5%8f%8amod_log_config-YNDFHlqiNP\">\u5b89\u88ddApache\u53camod_log_config<\/h2>\n<p>\u5728\u5927\u591a\u6578Linux\u767c\u884c\u7248\u4e2d\uff0cApache\u548cmod_log_config\u901a\u5e38\u662f\u9810\u88dd\u7684\u3002\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fUbuntu\u6216Debian\uff0c\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88ddApache\uff1a<\/p>\n<pre><code>sudo apt update\nsudo apt install apache2<\/code><\/pre>\n<p>\u5c0d\u65bcCentOS\u6216Red Hat\u7cfb\u7d71\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo yum install httpd<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5Apache\u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start apache2  # Ubuntu\/Debian\nsudo systemctl start httpd      # CentOS\/Red Hat<\/code><\/pre>\n<h2 id=\"%e8%a8%ad%e5%ae%9a%e6%97%a5%e8%aa%8c%e8%a8%98%e9%8c%84-YNDFHlqiNP\">\u8a2d\u5b9a\u65e5\u8a8c\u8a18\u9304<\/h2>\n<p>Apache\u7684\u65e5\u8a8c\u6587\u4ef6\u901a\u5e38\u4f4d\u65bc\u4ee5\u4e0b\u8def\u5f91\uff1a<\/p>\n<ul>\n<li>\/var\/log\/apache2\/access.log  (Ubuntu\/Debian)<\/li>\n<li>\/var\/log\/httpd\/access_log    (CentOS\/Red Hat)<\/li>\n<\/ul>\n<p>\u8981\u81ea\u5b9a\u7fa9\u65e5\u8a8c\u683c\u5f0f\uff0c\u4f60\u9700\u8981\u7de8\u8f2fApache\u7684\u914d\u7f6e\u6587\u4ef6\u3002\u9019\u901a\u5e38\u4f4d\u65bc\uff1a<\/p>\n<ul>\n<li>\/etc\/apache2\/apache2.conf  (Ubuntu\/Debian)<\/li>\n<li>\/etc\/httpd\/conf\/httpd.conf   (CentOS\/Red Hat)<\/li>\n<\/ul>\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6307\u4ee4\u4f86\u8a2d\u5b9a\u65e5\u8a8c\u683c\u5f0f\uff1a<\/p>\n<pre><code>LogFormat \"%h %l %u %t \"%r\" %&gt;s %b\" common\nCustomLog ${APACHE_LOG_DIR}\/access.log common<\/code><\/pre>\n<p>\u4e0a\u8ff0\u6307\u4ee4\u4e2d\uff0cLogFormat\u5b9a\u7fa9\u4e86\u65e5\u8a8c\u7684\u683c\u5f0f\uff0c\u5e38\u898b\u7684\u683c\u5f0f\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>%h &#8211; \u5ba2\u6236\u7aef\u7684IP\u5730\u5740<\/li>\n<li>%l &#8211; \u5ba2\u6236\u7aef\u7684\u8eab\u4efd\uff08\u901a\u5e38\u70ba&#8217;-&#8216;\uff09<\/li>\n<li>%u &#8211; \u767b\u9304\u7684\u7528\u6236\u540d\uff08\u5982\u679c\u6709\uff09<\/li>\n<li>%t &#8211; \u8acb\u6c42\u7684\u6642\u9593<\/li>\n<li>%r &#8211; \u8acb\u6c42\u7684\u7b2c\u4e00\u884c<\/li>\n<li>%&gt;s &#8211; \u4f3a\u670d\u5668\u7684\u56de\u61c9\u72c0\u614b\u78bc<\/li>\n<li>%b &#8211; \u56de\u61c9\u7684\u5b57\u7bc0\u6578<\/li>\n<\/ul>\n<h2 id=\"%e9%87%8d%e5%95%9fapache%e6%9c%8d%e5%8b%99-YNDFHlqiNP\">\u91cd\u555fApache\u670d\u52d9<\/h2>\n<p>\u5b8c\u6210\u914d\u7f6e\u5f8c\uff0c\u5fc5\u9808\u91cd\u555fApache\u670d\u52d9\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u555f\u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl restart apache2  # Ubuntu\/Debian\nsudo systemctl restart httpd      # CentOS\/Red Hat<\/code><\/pre>\n<h2 id=\"%e6%9f%a5%e7%9c%8b%e6%97%a5%e8%aa%8c%e6%96%87%e4%bb%b6-YNDFHlqiNP\">\u67e5\u770b\u65e5\u8a8c\u6587\u4ef6<\/h2>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u65e5\u8a8c\u6587\u4ef6\u7684\u5167\u5bb9\uff1a<\/p>\n<pre><code>tail -f \/var\/log\/apache2\/access.log  # Ubuntu\/Debian\ntail -f \/var\/log\/httpd\/access_log      # CentOS\/Red Hat<\/code><\/pre>\n<p>\u9019\u6a23\uff0c\u4f60\u5c31\u53ef\u4ee5\u5be6\u6642\u67e5\u770b\u8a2a\u554f\u8005\u7684\u8acb\u6c42\u548c\u4f3a\u670d\u5668\u7684\u56de\u61c9\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-YNDFHlqiNP\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4f7f\u7528mod_log_config\u6a21\u7d44\uff0cApache\u7528\u6236\u53ef\u4ee5\u9748\u6d3b\u5730\u8a2d\u5b9a\u65e5\u8a8c\u8a18\u9304\uff0c\u5f9e\u800c\u7372\u5f97\u6709\u95dc\u7db2\u7ad9\u8a2a\u554f\u7684\u8a73\u7d30\u4fe1\u606f\u3002\u9019\u5c0d\u65bc\u7db2\u7ad9\u7684\u7dad\u8b77\u548c\u6027\u80fd\u512a\u5316\u81f3\u95dc\u91cd\u8981\u3002\u5982\u679c\u4f60\u6b63\u5728\u5c0b\u627e\u7a69\u5b9a\u7684\u4f3a\u670d\u5668\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u6216<a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a>\u4f86\u652f\u6301\u4f60\u7684Apache\u4f3a\u670d\u5668\u904b\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b66\u4e60\u5982\u4f55\u4f7f\u7528mod_log_config\u8bbe\u7f6eApache\u670d\u52a1\u5668\uff0c\u4f18\u5316\u65e5\u5fd7\u8bb0\u5f55\uff0c\u63d0\u5347\u7f51\u7ad9\u6027\u80fd\u4e0e\u7ba1\u7406\u6548\u7387\u3002\u9002\u5408\u65b0\u624b\u5165\u95e8\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-41720","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=41720"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41720\/revisions"}],"predecessor-version":[{"id":41721,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41720\/revisions\/41721"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=41720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=41720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=41720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}