{"id":1870,"date":"2010-09-18T00:13:44","date_gmt":"2010-09-18T00:13:44","guid":{"rendered":"http:\/\/www.icocean.com\/blog\/?p=1870"},"modified":"1970-01-01T07:00:00","modified_gmt":"1970-01-01T07:00:00","slug":"apache%E6%80%A7%E8%83%BD%E8%B0%83%E6%A0%A1","status":"publish","type":"post","link":"https:\/\/www.icocean.com\/blog\/?p=1870","title":{"rendered":"Apache \u6027\u80fd\u8c03\u6821"},"content":{"rendered":"<p>Apache \u662f\u8001\u724c\u5b50\u7684\u7f51\u7ad9\u670d\u52a1\u5668\uff0c\u8bba\u529f\u80fd\u548c\u63d2\u4ef6\uff0c\u662f\u65e0\u51fa\u5176\u53f3\uff0c\u4f46\u662f\u8bba\u6027\u80fd\uff0c\u5f88\u591a\u65b0\u624b\u5df2\u7ecf\u628a Apache \u7529\u5728\u540e\u9762\uff0c\u5982 lighttpd, Nginx\u3002\u5728\u66f4\u6362Web\u670d\u52a1\u5668\u8f6f\u4ef6\u8fd9\u7c7b\u6fc0\u8fdb\u7684\u52a8\u4f5c\u4e4b\u524d\uff0c\u4f60\u5e94\u8be5\u8003\u8651\u4e00\u4e0b\uff1a\u5982\u679c\u60a8\u62e5\u6709\u8db3\u591f\u591a\u7684\u5185\u5b58\u6765\u5e94\u4ed8\u73b0\u6709\u7684\u5e76\u53d1\u8bbf\u95ee\u7684\u8bdd\uff0c\u5efa\u8bae\u4f60\u8fd8\u662f\u7ee7\u7eed\u4f7f\u7528 Apache\uff0c\u4f46\u662f\u4f5c\u4e9b\u6027\u80fd\u4e0a\u7684\u8c03\u6821\u662f\u5e94\u8be5\u7684\u3002<\/p>\n<p>\u5173\u4e8e ServerLimit&nbsp;&nbsp;\u548c MaxClients<br \/>MaxClients \u53c2\u6570\u51b3\u5b9a\u4e86 Apache \u6700\u5927\u5e76\u53d1\u8bbf\u95ee\u6570\u3002<\/p>\n<p>\u5bf9\u4e8e mpm_prefork\uff0c\u5982\u679c MaxClients \u8bbe\u7f6e\u8d85\u8fc7\u4e86 256\uff0c\u5c31\u9700\u8981\u5bf9 ServerLimit \u8bbe\u7f6e\uff0cServerLimit \u5e94\u8be5\u548c MaxClients \u4e00\u6837\uff0c\u81f3\u5c11\u4e0d\u5c0f\u4e8e MaxClient\u3002<\/p>\n<p>\u5bf9\u4e8e mpm_worker\uff0c\u5982\u679c MaxClients \u9664\u4ee5 ThreadsPerChild&nbsp;&nbsp;\u8d85\u8fc7\u4e86 16\uff0c\u5c31\u8981\u5bf9 ServerLimit \u8fdb\u884c\u8bbe\u7f6e\u3002ServerLimit \u4e58\u4ee5 ThreadsPerChild \u8981\u5927\u4e8e\u7b49\u4e8e MaxClients\u3002<\/p>\n<p>MaxClients \u4e0d\u662f\u968f\u610f\u8bbe\u5b9a\u7684<br \/>\u50cf Apache \u8fd9\u6837\u91cd\u91cf\u7ea7\u7684\u8f6f\u4ef6\uff0c\u5185\u5b58\u6d88\u8017\u662f\u5f88\u5927\u7684\u3002MaxClients \u7684\u8ba1\u7b97\u89c4\u5219\u662f Apache \u53ef\u5360\u7528\u7684\u7269\u7406\u5185\u5b58\uff0c\u9664\u4ee5\u5355\u4e2a Apache\u8fdb\u7a0b\u7684\u5185\u5b58\u5360\u7528\u3002<\/p>\n<p>\u56e0\u6b64\u5e76\u53d1\u6570\u76f4\u63a5\u53d6\u51b3\u4e8e\u5185\u5b58\u7684\u5927\u5c0f\u3002\u7136\u800c\u5982\u679c\u5185\u5b58\u8db3\u591f\u5927\uff0c\u800c\u914d\u7f6e\u6587\u4ef6\u6ca1\u6709\u8ddf\u4e0a\uff0c\u5c82\u4e0d\u662f\u5403\u4e8f\uff1f <!--more--><\/p>\n<p>\u7528MaxRequestsPerChild \u964d\u4f4e\u5185\u5b58\u6cc4\u6f0f\u7684\u5371\u5bb3<br \/>\u96be\u4fdd\u6709\u4ec0\u4e48Web \u5e94\u7528\/\u63d2\u4ef6\u4f1a\u5bfc\u81f4\u5185\u5b58\u6cc4\u6f0f\uff0c\u6211\u66fe\u7ecf\u6709\u8fc7\u4e00\u4e2a\u670d\u52a1\u5668\uff0c\u6bcf\u9694\u4e24\u5929\u5c31\u9700\u8981\u91cd\u542f\uff0c\u53ef\u80fd\u662f ssl \u6a21\u5757\u5bfc\u81f4\u7684\u5185\u5b58\u6cc4\u6f0f\u3002\u5982\u679c\u914d\u7f6e\u4e86 MaxRequestsPerChild\uff0c\u5c31\u4f1a\u5c06\u98ce\u9669\u964d\u5230\u6700\u5c0f\uff0c\u5f53\u4e00\u4e2a Apache \u8fdb\u7a0b\u670d\u52a1\u4e86 MaRequestsPerChild \u4e2a\u8bf7\u6c42\u540e\uff0c\u5c31\u4f1a\u6740\u6389\u81ea\u5df1\uff0c\u907f\u514d\u5185\u5b58\u6cc4\u6f0f\u3002<\/p>\n<p>\u7f3a\u7701 MaxRequestsPerChild \u7684\u914d\u7f6e\u4e3a 0, \u5219\u8fdb\u7a0b\u59cb\u7ec8\u63d0\u4f9b\u670d\u52a1\uff0c\u4e0d\u4f1a\u91cd\u751f\u4ee5\u91ca\u653e\u53ef\u80fd\u7684\u5185\u5b58\u6cc4\u6f0f\u3002<\/p>\n<p>\u7cbe\u96d5\u7ec6\u523b\u5f0f\u7684\u8c03\u4f18<br \/>\u6211\u89c1\u8fc7\u5f88\u591a\u670d\u52a1\u5668\u4f18\u5316\u7684\u6587\u7ae0\uff0c\u4ecb\u7ecd\u4e86\u4e00\u7cfb\u5217\u7cbe\u96d5\u7ec6\u523b\u5f0f\u7684\u8c03\u4f18\uff08\u53ea\u5728\u8bbf\u95ee\u91cf\u5de8\u5927\uff0cIO\u6210\u4e3a\u74f6\u9888\u7684\u65f6\u5019\u4f1a\u53c8\u6548\u679c\uff09\uff1a<\/p>\n<p>\u4ece\u5305\u62ec\u4e3a\u78c1\u76d8\u6302\u8f7d\u8bbe\u7f6e&nbsp;&nbsp;relatime \u53c2\u6570\uff0c\u4ee5\u907f\u514d\u5206\u533a\u5728\u8bfb\u53d6\u7684\u65f6\u5019\uff0c\u8fd8\u8981\u6267\u884c\u5199\u64cd\u4f5c\uff08\u5199\u5165\u8bbf\u95ee\u65f6\u95f4\uff09<br \/>\u4e3a \/ \u8bbe\u7f6e Options FollowSymLinks \u548c AllowOverride None\uff0c\u90fd\u662f\u4e3a\u4e86\u907f\u514d\u5728\u63d0\u4f9b Web \u5e94\u7528\u7684\u65f6\u5019\uff0c\u4e00\u4e9b\u4e0d\u5fc5\u8981\u7684\u6587\u4ef6\u68c0\u7d22\u64cd\u4f5c<br \/>\u4f7f\u7528 mod_cache \u6a21\u7ec4\uff0c\u63d0\u4f9b\u9875\u9762\u7f13\u5b58<br \/>\u6a21\u7ec4 mod_cache, \u5305\u62ec mod_disk_cache, mod_mem_cache\uff0c mod_file_cache \u53ef\u4ee5\u7528\u6765\u63d0\u4f9b\u9875\u9762\u7f13\u5b58\uff0c\u8fd9\u662f\u6709\u6548\u7684\u89e3\u51b3\u5e94\u7528\u6548\u7387\u4e0d\u9ad8\u7684\u74f6\u9888\u7684\u6700\u4f73\u65b9\u6cd5\u3002\u800c\u4e14 mod_cache \u7684\u914d\u7f6e\uff0c\u6bd4\u4f7f\u7528\u53cd\u5411\u4ee3\u7406\u6216\u8005 squid \u8981\u7b80\u4fbf\u7684\u591a\u3002<\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879\uff1a<\/p>\n<p>\u5728 \/etc\/default\/apache2 \u4e2d\uff0c\u8bbe\u7f6e HTCACHECLEAN_SIZE\uff0c\u6765\u6307\u5b9a\u7f13\u5b58\u7684\u5927\u5c0f<br \/>\u4f7f\u7528 disk_cache \u6bd4 mem_cache \u6765\u7684\u65b9\u4fbf<br \/>\u56e0\u4e3a mem_cache \u662f\u7ebf\u7a0b\u6709\u6548\u7684\uff0cmpm_prefork \u5355\u7ebf\u7a0b\uff0cmpm_work \u591a\u7ebf\u7a0b\u4f46\u662f\u4e5f\u4f1a\u914d\u7f6e\u591a\u4e2a\u8fdb\u7a0b\u3002<br \/>cache \u6a21\u7ec4\u7684\u53c2\u6570\u914d\u7f6e\u5f88\u6709\u5b66\u95ee\uff0c\u800c\u4e14\u548c\u5e94\u7528\u672c\u8eab\u63d0\u4f9b\u7684 Header \u4fe1\u606f\u662f\u5426\u5408\u7406\u6709\u5173<br \/>\u4f8b\u5982 Web \u670d\u52a1\u5668\u54cd\u5e94\u4e2d\u7684 Vary, Expiry, Last-Modified, no-cache, Etag \u7b49 Header \u90fd\u4f1a\u5bf9\u9875\u9762\u7f13\u5b58\u9020\u6210\u5f71\u54cd\u3002<br \/>\u5e94\u7528\u672c\u8eab\u7684\u4f18\u5316\uff0c\u662f\u66f4\u4e3a\u91cd\u8981<br \/>Web\u670d\u52a1\u5668\u7684\u4f18\u5316\uff0c\u4ee3\u66ff\u4e0d\u4e86\u5e94\u7528\u672c\u8eab\u7684\u4f18\u5316\u3002WordPress \u5c31\u662f\u4e00\u4f8b\u3002<\/p>\n<p>WordPress \u4f5c\u4e3a\u535a\u5ba2\u529f\u80fd\u975e\u5e38\u4e30\u5bcc\uff0c\u529f\u80fd\u6c38\u8fdc\u662f\u5176\u5f00\u53d1\u7b2c\u4e00\u4f4d\u7684\uff0c\u800c\u4ee3\u7801\u8d28\u91cf\uff1f\u529d\u4f60\u8fd8\u662f\u522b\u770b\u4ee3\u7801\u5427\u3002\u6027\u80fd\uff1f\u5982\u679c\u4e24\u4e2a\u4ee5\u4e0a\u7684\u5e76\u53d1\u8bbf\u95ee\uff0c\u53ef\u80fd\u5c31\u4f1a\u8ba9\u4e00\u4e2a\u53cc\u6838CPU\u7684\u670d\u52a1\u5668\u75b2\u4e8e\u5e94\u4ed8\u4e86\u3002<br \/>WordPress \u7684\u63d2\u4ef6\u4e2d\uff0c\u6709\u6570\u636e\u5e93\u7f13\u5b58\u7684\u63d2\u4ef6\uff0c\u53ef\u4ee5\u6709\u6548\u7684\u5bf9 SQL \u8bbf\u95ee\u8fdb\u884c\u7f13\u5b58\uff0c\u53ef\u80fd\u5c06\u51e0\u5341\u6b21 SQL \u8bbf\u95ee\u964d\u4f4e\u5230\u51e0\u6b21<br \/>WordPress \u7684\u63d2\u4ef6\u4e2d\uff0c\u4e5f\u6709\u9875\u9762\u7f13\u5b58\u7684\u63d2\u4ef6\uff0c\u6027\u80fd\u6bd4\u4e0d\u4e0a Apache mod_cache\uff0c\u4f46\u662f\u9488\u5bf9\u6027\u66f4\u5f3a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache \u662f\u8001\u724c\u5b50\u7684\u7f51\u7ad9\u670d\u52a1\u5668\uff0c\u8bba\u529f\u80fd\u548c\u63d2\u4ef6\uff0c\u662f\u65e0\u51fa\u5176\u53f3\uff0c\u4f46\u662f\u8bba\u6027\u80fd\uff0c\u5f88\u591a\u65b0\u624b\u5df2\u7ecf\u628a Apache \u7529\u5728\u540e <a href='https:\/\/www.icocean.com\/blog\/?p=1870' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[638,392,1881,2997],"class_list":["post-1870","post","type-post","status-publish","format-standard","hentry","category-lamp","tag-apache","tag-392","tag-1881","tag-2997","category-24-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1870"}],"version-history":[{"count":0,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1870\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}