{"id":77412,"date":"2026-02-24T15:59:18","date_gmt":"2026-02-24T07:59:18","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/77412.html"},"modified":"2026-02-24T15:59:18","modified_gmt":"2026-02-24T07:59:18","slug":"%e4%ba%91%e5%8e%9f%e7%94%9f%e4%bc%81%e4%b8%9a%e9%ab%98%e6%80%a7%e8%83%bd-web-%e6%9c%8d%e5%8a%a1%e5%99%a8nginx-%e6%a0%b8%e5%bf%83","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/77412.html","title":{"rendered":"\u4e91\u539f\u751f(\u4f01\u4e1a\u9ad8\u6027\u80fd Web \u670d\u52a1\u5668(Nginx \u6838\u5fc3))"},"content":{"rendered":"<h3>\u4e00\u3001Web \u670d\u52a1\u57fa\u7840\u4ecb\u7ecd<\/h3>\n<h4>1.1 Apache \u7ecf\u5178 Web \u670d\u52a1\u7aef<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"234\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075911-699d5a4fd7e88.png\" width=\"414\" \/><\/p>\n<p>Apache \u5386\u7ecf 1.X\u30012.X \u4e24\u5927\u7248\u672c&#xff0c;\u652f\u6301\u7f16\u8bd1\u5b89\u88c5\u5b9a\u5236\u529f\u80fd&#xff0c;\u6838\u5fc3\u6709\u4e09\u79cd\u5de5\u4f5c\u6a21\u578b&#xff0c;\u5747\u57fa\u4e8e\u591a\u8fdb\u7a0b \/ \u7ebf\u7a0b\u67b6\u6784&#xff0c;\u5404\u6709\u9002\u7528\u573a\u666f&#xff1a;<\/p>\n<table>\n<tr>\u6a21\u578b\u6838\u5fc3\u539f\u7406\u4f18\u70b9\u7f3a\u70b9\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>prefork&#xff08;\u9884\u6d3e\u751f&#xff09;<\/td>\n<td>\u4e3b\u8fdb\u7a0b\u751f\u6210\u591a\u4e2a\u72ec\u7acb\u5b50\u8fdb\u7a0b&#xff0c;\u5355\u8fdb\u7a0b\u5355\u7ebf\u7a0b&#xff0c;select \u6a21\u578b&#xff0c;\u6700\u5927\u5e76\u53d1 1024<\/td>\n<td>\u7a33\u5b9a\u6027\u6781\u9ad8&#xff0c;\u8fdb\u7a0b\u72ec\u7acb\u4e92\u4e0d\u5f71\u54cd<\/td>\n<td>\u5185\u5b58\u5360\u7528\u5927&#xff0c;\u5e76\u53d1\u80fd\u529b\u5f31&#xff0c;\u6bcf\u4e2a\u8bf7\u6c42\u5bf9\u5e94\u4e00\u4e2a\u8fdb\u7a0b<\/td>\n<td>\u8bbf\u95ee\u91cf\u5c0f\u3001\u5bf9\u7a33\u5b9a\u6027\u8981\u6c42\u9ad8\u7684\u573a\u666f<\/td>\n<\/tr>\n<tr>\n<td>worker&#xff08;\u591a\u8fdb\u7a0b\u591a\u7ebf\u7a0b&#xff09;<\/td>\n<td>\u4e3b\u8fdb\u7a0b\u542f\u52a8\u5b50\u8fdb\u7a0b&#xff0c;\u5b50\u8fdb\u7a0b\u5305\u542b\u56fa\u5b9a\u7ebf\u7a0b&#xff0c;\u7ebf\u7a0b\u5904\u7406\u8bf7\u6c42&#xff0c;\u7ebf\u7a0b\u4e0d\u8db3\u65f6\u65b0\u5efa\u5b50\u8fdb\u7a0b<\/td>\n<td>\u5185\u5b58\u5360\u7528\u6bd4 prefork \u5c11&#xff0c;\u5e76\u53d1\u80fd\u529b\u66f4\u9ad8<\/td>\n<td>keepalive \u957f\u8fde\u63a5\u4f1a\u5360\u7528\u7ebf\u7a0b\u81f3\u8d85\u65f6&#xff0c;\u9ad8\u5e76\u53d1\u4e0b\u6613\u65e0\u53ef\u7528\u7ebf\u7a0b<\/td>\n<td>\u4e2d\u7b49\u8bbf\u95ee\u91cf\u573a\u666f<\/td>\n<\/tr>\n<tr>\n<td>event&#xff08;\u4e8b\u4ef6\u9a71\u52a8&#xff09;<\/td>\n<td>2.4.X \u7248\u672c\u6b63\u5f0f\u652f\u6301&#xff0c;epoll \u6a21\u578b&#xff0c;\u4e0e worker \u7c7b\u4f3c&#xff0c;\u65b0\u589e\u4e13\u95e8\u7ebf\u7a0b\u7ba1\u7406 keepalive \u7ebf\u7a0b<\/td>\n<td>\u5355\u7ebf\u7a0b\u54cd\u5e94\u591a\u8bf7\u6c42&#xff0c;\u5185\u5b58\u5360\u7528\u6700\u4f4e&#xff0c;\u9ad8\u5e76\u53d1\u8868\u73b0\u4f18\u79c0&#xff0c;\u89e3\u51b3 keepalive \u7ebf\u7a0b\u8d44\u6e90\u6d6a\u8d39<\/td>\n<td>\u65e0\u7ebf\u7a0b\u5b89\u5168\u63a7\u5236<\/td>\n<td>\u9ad8\u5e76\u53d1\u8bbf\u95ee\u573a\u666f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Apache prefork \u6a21\u578b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"350\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075912-699d5a5008dc4.png\" width=\"978\" \/><\/p>\n<p>Apache worker \u6a21\u578b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"513\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075912-699d5a5030d1f.png\" width=\"938\" \/><\/p>\n<p>Apache event\u6a21\u578b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"554\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075912-699d5a50600a1.png\" width=\"1013\" \/><\/p>\n<h4>1.2 Nginx \u9ad8\u6027\u80fd Web \u670d\u52a1\u7aef<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"304\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075912-699d5a5099d8c.png\" width=\"579\" \/><\/p>\n<h5>1.2.1 \u57fa\u7840\u4fe1\u606f<\/h5>\n<ul>\n<li>\u5f00\u53d1\u8005&#xff1a;\u4f0a\u6208\u5c14\u30fb\u8d5b\u7d22\u8036\u592b&#xff0c;\u4e3a\u4fc4\u7f57\u65aframbler.ru\u5f00\u53d1&#xff0c;2004 \u5e74\u9996\u6b21\u516c\u5f00\u53d1\u5e03&#xff0c;2019 \u5e74\u88ab F5 \u4ee5 6.7 \u4ebf\u7f8e\u5143\u6536\u8d2d\u3002<\/li>\n<li>\u7248\u672c\u5206\u7c7b&#xff1a;\u5f00\u53d1\u7248\u3001\u7a33\u5b9a\u7248\u3001\u8fc7\u671f\u7248&#xff0c;\u6838\u5fc3\u6a21\u5757\u4ee3\u7801\u91cf\u7ea6 19.8 \u4e07\u884c\u3002<\/li>\n<li>\u5b98\u7f51&#xff1a;www.nginx.org\u3002<\/li>\n<li>\u884c\u4e1a\u5e94\u7528&#xff1a;\u5929\u732b\u3001\u6dd8\u5b9d\u3001\u4eac\u4e1c\u3001\u5c0f\u7c73\u7b49\u4e00\u7ebf\u4e92\u8054\u7f51\u516c\u53f8\u5747\u4f7f\u7528\u6216\u4e8c\u6b21\u5f00\u53d1\u3002<\/li>\n<\/ul>\n<h5>1.2.2 \u6838\u5fc3\u4f18\u52bf\u4e0e\u529f\u80fd<\/h5>\n<ul>\n<li>\u9ad8\u6027\u80fd&#xff1a;\u89e3\u51b3 C10K&#xff08;\u4e07\u7ea7\u8fde\u63a5&#xff09;\u95ee\u9898&#xff0c;\u4f4e\u5185\u5b58\u6d88\u8017&#xff08;10000 \u4e2a keep-alive \u975e\u6d3b\u52a8\u8fde\u63a5\u4ec5\u9700 2.5M \u5185\u5b58&#xff09;\u3002<\/li>\n<li>\u529f\u80fd\u4e30\u5bcc&#xff1a;\u53ef\u4f5c\u4e3a HTTP\/HTTPS \u670d\u52a1\u5668\u3001\u53cd\u5411\u4ee3\u7406\u3001\u90ae\u4ef6\u4ee3\u7406\u3001TCP\/UDP \u4ee3\u7406&#xff1b;\u652f\u6301 FastCGI\u3001SSL\u3001\u865a\u62df\u4e3b\u673a\u3001URL \u91cd\u5199\u3001Gzip\u3001\u8d1f\u8f7d\u5747\u8861&#xff08;1.9 &#043; \u5f00\u542f stream \u6a21\u5757&#xff09;&#xff0c;\u652f\u6301\u7b2c\u4e09\u65b9\u6269\u5c55\u3002<\/li>\n<li>\u9ad8\u53ef\u9760\u6027&#xff1a;\u6a21\u5757\u5316\u8bbe\u8ba1\u3001\u652f\u6301\u70ed\u90e8\u7f72&#xff08;\u4e0d\u505c\u673a\u66f4\u65b0\u914d\u7f6e \/ \u5347\u7ea7 \/ \u6362\u65e5\u5fd7&#xff09;\u3002<\/li>\n<\/ul>\n<h5>1.2.3 \u5178\u578b\u5de5\u4f5c\u573a\u666f<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"358\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075912-699d5a50b3ceb.png\" width=\"881\" \/><\/p>\n<p>Nginx \u524d\u7f6e\u5904\u7406\u8bf7\u6c42&#xff0c;\u9759\u6001\u8d44\u6e90\u76f4\u63a5\u8fd4\u56de&#xff0c;\u52a8\u6001\u8d44\u6e90\u8f6c\u53d1\u81f3 Tomcat \u7b49\u5e94\u7528\u670d\u52a1\u5668&#xff0c;\u6570\u636e\u5b58\u50a8\u81f3 MySQL&#xff0c;\u56fe\u7247\u7b49\u8d44\u6e90\u7531\u4e13\u7528\u5b58\u50a8\u670d\u52a1\u5668\u63d0\u4f9b&#xff0c;\u5b9e\u73b0\u52a8\u9759\u5206\u79bb\u4e0e\u670d\u52a1\u5206\u5c42\u3002<\/p>\n<h4>1.3 \u670d\u52a1\u7aef I\/O \u6d41\u7a0b<\/h4>\n<h5>1.3.1 \u6838\u5fc3\u6982\u5ff5<\/h5>\n<ul>\n<li>I\/O&#xff1a;Input\/Output&#xff0c;\u6307\u7528\u6237\u7a7a\u95f4\u8fdb\u7a0b\u4e0e\u5185\u6838\u7a7a\u95f4\u7684\u6570\u636e\u4ea4\u6362&#xff0c;\u9700\u5c06\u5185\u6838\u5185\u5b58\u6570\u636e\u590d\u5236\u5230\u7528\u6237\u8fdb\u7a0b\u5185\u5b58\u3002<\/li>\n<li>IOPS&#xff1a;\u6bcf\u79d2\u8f93\u5165\u8f93\u51fa\u91cf&#xff0c;\u8861\u91cf\u78c1\u76d8\u6027\u80fd\u7684\u6838\u5fc3\u6307\u6807&#xff0c;\u6307\u5355\u4f4d\u65f6\u95f4\u5185\u5904\u7406\u7684\u8bfb \/ \u5199\u8bf7\u6c42\u6570\u3002<\/li>\n<li>\u670d\u52a1\u5668 I\/O \u7c7b\u578b&#xff1a;\u78c1\u76d8 I\/O&#xff08;\u8fdb\u7a0b\u8bf7\u6c42\u78c1\u76d8\u8d44\u6e90&#xff0c;\u5185\u6838\u52a0\u8f7d\u540e\u590d\u5236\u81f3\u8fdb\u7a0b&#xff09;\u3001\u7f51\u7edc I\/O&#xff08;\u5bf9 socket \u6587\u4ef6\u7684\u8bfb\u5199&#xff0c;\u7f51\u7edc\u534f\u8bae\u6808\u4e0e\u7528\u6237\u8fdb\u7a0b\u7684\u6570\u636e\u4ea4\u6362&#xff09;\u3002<\/li>\n<\/ul>\n<h5>1.3.2 \u901a\u7528 I\/O \u9636\u6bb5<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"454\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075912-699d5a50e34be.png\" width=\"889\" \/><\/p>\n<p>\u65e0\u8bba\u78c1\u76d8 \/ \u7f51\u7edc I\/O&#xff0c;\u5747\u5206\u4e3a\u4e24\u4e2a\u9636\u6bb5&#xff1a;<\/p>\n<li>\u6570\u636e\u4ece\u6587\u4ef6 \/ \u7f51\u5361\u52a0\u8f7d\u81f3\u5185\u6838\u5185\u5b58\u7f13\u51b2\u533a&#xff0c;\u7b49\u5f85\u6570\u636e\u51c6\u5907\u5b8c\u6210&#xff08;\u8017\u65f6\u8f83\u957f&#xff09;&#xff1b;<\/li>\n<li>\u6570\u636e\u4ece\u5185\u6838\u7f13\u51b2\u533a\u590d\u5236\u81f3\u7528\u6237\u7a7a\u95f4\u8fdb\u7a0b\u5185\u5b58&#xff08;\u8017\u65f6\u8f83\u77ed&#xff09;\u3002<\/li>\n<h4>1.4 I\/O \u6a21\u578b<\/h4>\n<p>I\/O \u6a21\u578b\u7684\u6838\u5fc3\u533a\u5206\u7ef4\u5ea6\u4e3a\u540c\u6b65 \/ \u5f02\u6b65&#xff08;\u6d88\u606f\u901a\u4fe1\u673a\u5236&#xff0c;\u662f\u5426\u4e3b\u52a8\u901a\u77e5\u5904\u7406\u7ed3\u679c&#xff09;\u3001\u963b\u585e \/ \u975e\u963b\u585e&#xff08;\u7b49\u5f85\u7ed3\u679c\u65f6\u7684\u8fdb\u7a0b\u72b6\u6001&#xff0c;\u662f\u5426\u88ab\u6302\u8d77&#xff09;&#xff0c;\u4e3b\u6d41\u6709 5 \u79cd\u7f51\u7edc I\/O \u6a21\u578b&#xff0c;\u524d 4 \u79cd\u4e3a\u540c\u6b65 I\/O&#xff0c;\u4ec5\u5f02\u6b65 I\/O \u4e3a\u7eaf\u5f02\u6b65\u3002<\/p>\n<h5>1.4.1 \u6838\u5fc3\u6982\u5ff5<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"244\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075913-699d5a512b145.png\" width=\"925\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"206\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075913-699d5a515956e.png\" width=\"892\" \/><\/p>\n<ul>\n<li>\u540c\u6b65&#xff1a;\u88ab\u8c03\u7528\u8005\u4e0d\u4e3b\u52a8\u901a\u77e5\u7ed3\u679c&#xff0c;\u8c03\u7528\u8005\u9700\u4e3b\u52a8\u67e5\u8be2&#xff1b;<\/li>\n<li>\u5f02\u6b65&#xff1a;\u88ab\u8c03\u7528\u8005\u901a\u8fc7\u72b6\u6001 \/ \u901a\u77e5 \/ \u56de\u8c03\u4e3b\u52a8\u544a\u77e5\u8c03\u7528\u8005\u8fd0\u884c\u72b6\u6001&#xff1b;<\/li>\n<li>\u963b\u585e&#xff1a;IO \u64cd\u4f5c\u5b8c\u6210\u524d&#xff0c;\u8fdb\u7a0b\u88ab\u6302\u8d77&#xff0c;\u65e0\u6cd5\u6267\u884c\u5176\u4ed6\u64cd\u4f5c&#xff1b;<\/li>\n<li>\u975e\u963b\u585e&#xff1a;IO \u64cd\u4f5c\u8c03\u7528\u540e\u7acb\u5373\u8fd4\u56de\u72b6\u6001&#xff0c;\u8fdb\u7a0b\u4e0d\u6302\u8d77&#xff0c;\u53ef\u6267\u884c\u5176\u4ed6\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<h5>1.4.2 5 \u79cd\u7f51\u7edc I\/O \u6a21\u578b\u8be6\u89e3<\/h5>\n<li>\u963b\u585e\u578b I\/O&#xff08;blocking IO&#xff09;\n<ul>\n<li>\u539f\u7406&#xff1a;\u7528\u6237\u7ebf\u7a0b\u53d1\u8d77\u7cfb\u7edf\u8c03\u7528\u540e&#xff0c;\u5168\u7a0b\u963b\u585e&#xff0c;\u76f4\u81f3\u6570\u636e\u4ece\u5185\u6838\u590d\u5236\u81f3\u7528\u6237\u7a7a\u95f4&#xff1b;<\/li>\n<li>\u4f18\u70b9&#xff1a;\u7a0b\u5e8f\u7b80\u5355&#xff0c;\u963b\u585e\u671f\u95f4\u57fa\u672c\u4e0d\u5360\u7528 CPU&#xff1b;<\/li>\n<li>\u7f3a\u70b9&#xff1a;\u5355\u8fde\u63a5\u5355\u8fdb\u7a0b \/ \u7ebf\u7a0b&#xff0c;\u5e76\u53d1\u9ad8\u65f6\u5185\u5b58\u3001\u7ebf\u7a0b\u5207\u6362\u5f00\u9500\u5927&#xff08;Apache prefork \u57fa\u4e8e\u6b64&#xff09;\u3002<\/li>\n<li><\/li>\n<\/ul>\n<\/li>\n<li><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"484\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075913-699d5a5182fbb.png\" width=\"991\" \/>\u975e\u963b\u585e\u578b I\/O&#xff08;nonblocking IO&#xff09;\n<ul>\n<li>\u539f\u7406&#xff1a;\u7528\u6237\u7ebf\u7a0b\u53d1\u8d77\u8c03\u7528\u540e\u7acb\u5373\u8fd4\u56de&#xff0c;\u65e0\u6570\u636e\u5219\u8fd4\u56de\u9519\u8bef&#xff0c;\u901a\u8fc7\u8f6e\u8be2\u53cd\u590d\u53d1\u8d77\u8c03\u7528&#xff0c;\u76f4\u5230\u83b7\u53d6\u6570\u636e&#xff1b;<\/li>\n<li>\u7f3a\u70b9&#xff1a;\u8f6e\u8be2\u6d88\u8017\u5927\u91cf CPU&#xff0c;\u4e0a\u4e0b\u6587\u5207\u6362\u9891\u7e41&#xff0c;\u5b9e\u9645\u6781\u5c11\u5355\u72ec\u4f7f\u7528\u3002<\/li>\n<li><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"550\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075913-699d5a51dd339.png\" width=\"1008\" \/><\/li>\n<\/ul>\n<\/li>\n<li>\u4fe1\u53f7\u9a71\u52a8\u5f0f I\/O&#xff08;signal-driven IO&#xff09;\n<ul>\n<li>\u539f\u7406&#xff1a;\u901a\u8fc7 sigaction \u6ce8\u518c\u4fe1\u53f7\u5904\u7406\u51fd\u6570&#xff0c;\u8fdb\u7a0b\u7ee7\u7eed\u6267\u884c&#xff0c;\u5185\u6838\u6570\u636e\u5c31\u7eea\u65f6\u53d1\u9001 SIGIO \u4fe1\u53f7&#xff0c;\u8fdb\u7a0b\u5728\u56de\u8c03\u4e2d\u83b7\u53d6\u6570\u636e&#xff1b;<\/li>\n<li>\u4f18\u70b9&#xff1a;\u7b49\u5f85\u6570\u636e\u65f6\u8fdb\u7a0b\u4e0d\u963b\u585e&#xff0c;\u8d44\u6e90\u5229\u7528\u7387\u9ad8&#xff1b;<\/li>\n<li>\u7f3a\u70b9&#xff1a;\u5927\u91cf IO \u64cd\u4f5c\u65f6\u4fe1\u53f7\u961f\u5217\u6613\u6ea2\u51fa&#xff0c;\u65e0\u6cd5\u901a\u77e5\u3002<\/li>\n<li><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"559\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075914-699d5a52232ce.png\" width=\"993\" \/><\/li>\n<\/ul>\n<\/li>\n<li>\u5f02\u6b65 I\/O&#xff08;asynchronous IO&#xff09;\n<ul>\n<li>\u539f\u7406&#xff1a;\u7528\u6237\u7ebf\u7a0b\u53d1\u8d77 aio_read \u540e\u7acb\u5373\u8fd4\u56de&#xff0c;\u5185\u6838\u5b8c\u6210\u6570\u636e\u51c6\u5907 &#043; \u590d\u5236\u5168\u6d41\u7a0b\u540e&#xff0c;\u4e3b\u52a8\u901a\u77e5\u8fdb\u7a0b&#xff1b;<\/li>\n<li>\u4f18\u70b9&#xff1a;\u5145\u5206\u5229\u7528 DMA \u7279\u6027&#xff0c;I\/O \u4e0e\u8ba1\u7b97\u91cd\u53e0&#xff0c;\u5168\u7a0b\u975e\u963b\u585e&#xff1b;<\/li>\n<li>\u7f3a\u70b9&#xff1a;\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u73b0\u590d\u6742&#xff0c;Linux 2.6 \u624d\u5f15\u5165&#xff0c;AIO \u4e0d\u5b8c\u5584&#xff0c;\u5e38\u7528\u5f00\u6e90\u5e93&#xff08;libevent\u3001libev&#xff09;\u5b9e\u73b0\u3002<\/li>\n<li><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"538\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075914-699d5a52967be.png\" width=\"960\" \/><\/li>\n<\/ul>\n<\/li>\n<li>\u591a\u8def\u590d\u7528 I\/O&#xff08;I\/O multiplexing&#xff09;\n<ul>\n<li>\u539f\u7406&#xff1a;\u5355\u4e2a\u7ebf\u7a0b\u901a\u8fc7 select\/poll\/epoll \u7cfb\u7edf\u8c03\u7528&#xff0c;\u540c\u65f6\u76d1\u63a7\u591a\u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff08;socket&#xff09;&#xff0c;\u5185\u6838\u53d1\u73b0\u4efb\u4e00\u63cf\u8ff0\u7b26\u5c31\u7eea\u540e\u901a\u77e5\u7ebf\u7a0b&#xff0c;\u7ebf\u7a0b\u518d\u5904\u7406\u5bf9\u5e94\u8bf7\u6c42&#xff1b;<\/li>\n<li>\u6838\u5fc3\u5b9e\u73b0&#xff1a;select&#xff08;\u6570\u7ec4&#xff0c;\u6700\u5927\u8fde\u63a5 1024\/2048&#xff09;\u3001poll&#xff08;\u94fe\u8868&#xff0c;\u65e0\u8fde\u63a5\u4e0a\u9650&#xff09;\u3001epoll&#xff08;\u54c8\u5e0c\u8868&#xff0c;\u65e0\u8fde\u63a5\u4e0a\u9650&#xff0c;\u4e8b\u4ef6\u56de\u8c03&#xff09;&#xff1b;<\/li>\n<li>\u4f18\u70b9&#xff1a;\u5355\u7ebf\u7a0b\u5904\u7406\u591a\u8fde\u63a5&#xff0c;\u8282\u7701\u7cfb\u7edf\u8d44\u6e90&#xff1b;<\/li>\n<li>\u7f3a\u70b9&#xff1a;\u8fde\u63a5\u6570\u5c11\u65f6\u6548\u7387\u4f4e\u4e8e\u591a\u7ebf\u7a0b &#043; \u963b\u585e I\/O&#xff0c;\u9700\u4e24\u6b21\u7cfb\u7edf\u8c03\u7528&#xff1b;<\/li>\n<li>\u9002\u7528\u573a\u666f&#xff1a;\u591a\u8fde\u63a5\u3001\u591a\u534f\u8bae\u3001\u591a\u670d\u52a1\u7684\u670d\u52a1\u5668\u573a\u666f&#xff08;Nginx \u6838\u5fc3\u6a21\u578b&#xff09;\u3002<\/li>\n<li><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"513\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075914-699d5a52ecaed.png\" width=\"1026\" \/><\/li>\n<\/ul>\n<\/li>\n<h5>1.4.3 select\/poll\/epoll \u5bf9\u6bd4<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"539\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075915-699d5a534b0e0.png\" width=\"929\" \/><\/p>\n<table>\n<tr>\u7279\u6027selectpollepoll<\/tr>\n<tbody>\n<tr>\n<td>\u64cd\u4f5c\u65b9\u5f0f<\/td>\n<td>\u7ebf\u6027\u904d\u5386<\/td>\n<td>\u7ebf\u6027\u904d\u5386<\/td>\n<td>\u4e8b\u4ef6\u56de\u8c03<\/td>\n<\/tr>\n<tr>\n<td>\u5e95\u5c42\u5b9e\u73b0<\/td>\n<td>\u6570\u7ec4<\/td>\n<td>\u94fe\u8868<\/td>\n<td>\u54c8\u5e0c\u8868<\/td>\n<\/tr>\n<tr>\n<td>IO \u6548\u7387<\/td>\n<td>O(n)<\/td>\n<td>O(n)<\/td>\n<td>O(1)<\/td>\n<\/tr>\n<tr>\n<td>\u6700\u5927\u8fde\u63a5\u6570<\/td>\n<td>1024(x86)\/2048(x64)<\/td>\n<td>\u65e0\u4e0a\u9650<\/td>\n<td>\u65e0\u4e0a\u9650<\/td>\n<\/tr>\n<tr>\n<td>IO \u62f7\u8d1d<\/td>\n<td>\u6bcf\u6b21\u8c03\u7528\u5747\u4ece\u7528\u6237\u6001\u62f7\u8d1d\u81f3\u5185\u6838\u6001<\/td>\n<td>\u6bcf\u6b21\u8c03\u7528\u5747\u4ece\u7528\u6237\u6001\u62f7\u8d1d\u81f3\u5185\u6838\u6001<\/td>\n<td>\u4ec5 epoll_ctl \u65f6\u62f7\u8d1d&#xff0c;epoll_wait \u4e0d\u62f7\u8d1d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>1.5 \u96f6\u62f7\u8d1d<\/h4>\n<h5>1.5.1 \u4f20\u7edf Linux I\/O \u95ee\u9898<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"623\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075915-699d5a5396904.png\" width=\"871\" \/><\/p>\n<p>\u6807\u51c6 I\/O \u63a5\u53e3&#xff08;read\/write&#xff09;\u57fa\u4e8e\u6570\u636e\u62f7\u8d1d&#xff0c;\u9700\u7ecf\u8fc7\u7528\u6237\u6001 &#8211; \u5185\u6838\u6001\u591a\u6b21\u5207\u6362&#xff0c;\u6570\u636e\u62f7\u8d1d\u8017\u65f6\u5360\u6bd4\u8fbe 57.1%&#xff0c;\u4e25\u91cd\u6d88\u8017 CPU&#xff0c;\u964d\u4f4e\u4f20\u8f93\u6027\u80fd\u3002<\/p>\n<h5>1.5.2 \u96f6\u62f7\u8d1d\u6838\u5fc3\u601d\u60f3<\/h5>\n<p>\u5e76\u975e\u771f\u6b63 \u201c0 \u62f7\u8d1d\u201d&#xff0c;\u800c\u662f\u901a\u8fc7\u51cf\u5c11\u7528\u6237\u6001\u4e0e\u5185\u6838\u6001\u4e4b\u95f4\u7684\u62f7\u8d1d\u3001\u964d\u4f4e\u4e0a\u4e0b\u6587\u5207\u6362&#xff0c;\u7f13\u89e3 CPU \u538b\u529b&#xff0c;\u6838\u5fc3\u6280\u672f\u4e3a MMAP \u548c SENDFILE\u3002<\/p>\n<h5>1.5.3 \u6838\u5fc3\u96f6\u62f7\u8d1d\u6280\u672f<\/h5>\n<li>MMAP&#xff08;\u5185\u5b58\u6620\u5c04&#xff09;&#xff1a;\u5c06\u78c1\u76d8\u6587\u4ef6\u6620\u5c04\u81f3\u8fdb\u7a0b\u865a\u62df\u5730\u5740\u7a7a\u95f4&#xff0c;\u8fdb\u7a0b\u53ef\u76f4\u63a5\u8bbf\u95ee\u5185\u6838\u7f13\u51b2\u533a&#xff08;page cache&#xff09;&#xff0c;\u51cf\u5c11\u4e00\u6b21\u5185\u6838\u6001\u5230\u7528\u6237\u6001\u7684\u62f7\u8d1d&#xff0c;\u9002\u5408\u5927\u91cf\u6570\u636e\u4f20\u8f93&#xff1b;<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"686\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075915-699d5a53eb87d.png\" width=\"987\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"971\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075916-699d5a5453e9d.png\" width=\"1033\" \/><\/li>\n<li>SENDFILE&#xff1a;\u6570\u636e\u76f4\u63a5\u5728\u5185\u6838\u7f13\u51b2\u533a\u4e0e socket \u7f13\u51b2\u533a\u4e4b\u95f4\u4f20\u8f93&#xff0c;\u5168\u7a0b\u4e0d\u7ecf\u8fc7\u7528\u6237\u6001&#xff0c;\u5f7b\u5e95\u6d88\u9664\u7528\u6237\u6001 &#8211; \u5185\u6838\u6001\u7684\u62f7\u8d1d&#xff0c;\u9002\u5408\u9759\u6001\u6587\u4ef6\u4f20\u8f93&#xff08;Nginx \u9ed8\u8ba4\u542f\u7528&#xff09;\u3002<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"624\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075916-699d5a54d30d6.png\" width=\"930\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"693\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075917-699d5a551a34b.png\" width=\"911\" \/><\/li>\n<h3>\u4e8c\u3001Nginx \u67b6\u6784\u548c\u5b89\u88c5<\/h3>\n<h4>2.1 Nginx \u6982\u8ff0<\/h4>\n<li>\u547d\u540d&#xff1a;engine X&#xff0c;\u8f7b\u91cf\u7ea7\u9ad8\u6027\u80fd\u670d\u52a1\u5668&#xff0c;\u5206\u4e3a\u793e\u533a\u7248&#xff08;\u5f00\u6e90\u514d\u8d39&#xff09;\u548c\u5546\u4e1a\u7248&#xff08;Nginx Plus&#xff09;&#xff1b;<\/li>\n<li>\u4e8c\u6b21\u53d1\u884c\u7248&#xff1a;\n<ul>\n<li>Tengine&#xff1a;\u6dd8\u5b9d\u53d1\u8d77&#xff0c;\u57fa\u4e8e Nginx \u6dfb\u52a0\u9ad8\u7ea7\u529f\u80fd&#xff0c;\u9002\u7528\u4e8e\u5927\u8bbf\u95ee\u91cf\u7f51\u7ad9&#xff1b;<\/li>\n<li>OpenResty&#xff1a;\u7ae0\u4ea6\u6625\u56e2\u961f\u5f00\u53d1&#xff0c;\u57fa\u4e8e Nginx&#043;Lua&#xff0c;\u9ad8\u6027\u80fd Web \u5e73\u53f0&#xff0c;\u652f\u6301\u8d85\u9ad8\u5e76\u53d1&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>\u6838\u5fc3\u5b9a\u4f4d&#xff1a;HTTP\/HTTPS \u670d\u52a1\u5668\u3001\u53cd\u5411\u4ee3\u7406\u3001TCP\/UDP \u4ee3\u7406\u3001\u90ae\u4ef6\u4ee3\u7406&#xff0c;\u89e3\u51b3 C10K \u95ee\u9898\u3002<\/li>\n<h4>2.2 Nginx \u6838\u5fc3\u529f\u80fd<\/h4>\n<li>\u9759\u6001\u8d44\u6e90\u670d\u52a1&#xff1a;\u9ad8\u6548\u5904\u7406 HTML\u3001\u56fe\u7247\u3001JS\u3001CSS \u7b49\u9759\u6001\u6587\u4ef6&#xff1b;<\/li>\n<li>\u53cd\u5411\u4ee3\u7406&#xff1a;\u652f\u6301 HTTP\/HTTPS\u3001TCP\/UDP\u3001FastCGI\/uWSGI\/SCGI\u3001imap4\/pop3 \u7b49\u534f\u8bae&#xff1b;<\/li>\n<li>\u57fa\u7840\u7279\u6027&#xff1a;\u6a21\u5757\u5316\u8bbe\u8ba1\u3001\u9ad8\u53ef\u9760\u6027\u3001\u70ed\u90e8\u7f72\u3001\u4f4e\u5185\u5b58\u6d88\u8017\u3001\u4e8b\u4ef6\u9a71\u52a8&#xff08;epoll&#xff09;&#043;AIO&#043;MMAP&#043;SENDFILE&#xff1b;<\/li>\n<li>Web \u76f8\u5173\u529f\u80fd&#xff1a;\u865a\u62df\u4e3b\u673a\u3001keep-alive\u3001\u8bbf\u95ee\u65e5\u5fd7\u3001URL \u91cd\u5199\u3001IP \/ \u7528\u6237\u8bbf\u95ee\u63a7\u5236\u3001\u901f\u7387 \/ \u5e76\u53d1\u9650\u5236\u3001\u5728\u7ebf\u5347\u7ea7\u3002<\/li>\n<h4>2.3 Nginx \u8fdb\u7a0b\u67b6\u6784<\/h4>\n<p>Nginx \u91c7\u7528Master-Worker\u591a\u8fdb\u7a0b\u6a21\u578b&#xff0c;\u4e3b\u8fdb\u7a0b\u4e0e\u5de5\u4f5c\u8fdb\u7a0b\u5206\u5de5\u660e\u786e&#xff0c;\u8fdb\u7a0b\u95f4\u901a\u8fc7\u7ba1\u9053\u3001\u5171\u4eab\u5185\u5b58\u901a\u4fe1&#xff0c;\u652f\u6301\u5e73\u6ed1\u5347\u7ea7\u548c\u6545\u969c\u91cd\u542f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"595\" src=\"2026-02-24xmqvzueurqt.png\" width=\"1005\" \/><\/p>\n<h5>2.3.1 \u8fdb\u7a0b\u7ed3\u6784\u4e0e\u529f\u80fd<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"383\" src=\"2026-02-24gqaazaxmnc2.png\" width=\"880\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"623\" src=\"2026-02-244d3rsw41h2i.png\" width=\"1071\" \/><\/p>\n<table>\n<tr>\u8fdb\u7a0b\u7c7b\u578b\u6838\u5fc3\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>Master&#xff08;\u4e3b\u8fdb\u7a0b&#xff09;<\/td>\n<td>\u8bfb\u53d6 \/ \u9a8c\u8bc1\u914d\u7f6e\u3001\u7ba1\u7406 Worker \u8fdb\u7a0b\u3001\u76d1\u63a7 Worker \u72b6\u6001&#xff08;\u5f02\u5e38\u81ea\u52a8\u91cd\u542f&#xff09;\u3001\u7ed1\u5b9a \/ \u5173\u95ed socket\u3001\u63a5\u6536\u5916\u90e8\u6307\u4ee4&#xff08;\u91cd\u542f \/ \u5347\u7ea7 \/ \u9000\u51fa&#xff09;\u3001\u5b9e\u73b0\u5e73\u6ed1\u5347\u7ea7\u3001\u5f00\u542f\u65e5\u5fd7\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>Worker&#xff08;\u5de5\u4f5c\u8fdb\u7a0b&#xff09;<\/td>\n<td>\u5904\u7406\u5b9e\u9645\u7f51\u7edc\u8bf7\u6c42\u3001\u5e73\u7b49\u7ade\u4e89\u65b0\u8fde\u63a5\u3001I\/O \u8c03\u7528\u3001\u4e0e\u540e\u7aef\u670d\u52a1\u5668\u901a\u4fe1\u3001\u7f13\u5b58\u6570\u636e\u3001\u53d1\u9001\u54cd\u5e94\u7ed3\u679c\u3001\u63a5\u6536\u4e3b\u8fdb\u7a0b\u6307\u4ee4&#xff1b;\u6570\u91cf\u4e00\u822c\u7b49\u4e8e CPU \u6838\u5fc3\u6570&#xff0c;\u907f\u514d\u8fdb\u7a0b\u7ade\u4e89 CPU<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>2.3.2 \u8fdb\u7a0b\u95f4\u901a\u4fe1<\/h5>\n<li>Master \u4e0e Worker&#xff1a;Master \u901a\u8fc7\u5355\u5411\u7ba1\u9053\u5411 Worker \u53d1\u9001\u6307\u4ee4&#xff0c;Worker \u6355\u83b7\u7ba1\u9053\u53ef\u8bfb\u4e8b\u4ef6\u5e76\u6267\u884c\u64cd\u4f5c&#xff1b;Master \u901a\u8fc7 fork () \u751f\u6210 Worker&#xff0c;\u7ef4\u62a4\u5de5\u4f5c\u8fdb\u7a0b\u8868&#xff1b;<\/li>\n<li>Worker \u4e4b\u95f4&#xff1a;\u901a\u8fc7 Master \u8f6c\u53d1\u7ba1\u9053\u4fe1\u606f\u5b9e\u73b0\u901a\u4fe1&#xff0c;\u6216\u901a\u8fc7\u5171\u4eab\u5185\u5b58&#xff08;\u5982 upstream zone\u3001limit_req&#xff09;\u901a\u4fe1\u3002<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"391\" src=\"2026-02-24pfdelparrbp.png\" width=\"996\" \/><\/li>\n<h5>2.3.3 Nginx \u542f\u52a8\u4e0e HTTP \u8fde\u63a5\u5efa\u7acb<\/h5>\n<li>Master \u8fdb\u7a0b\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6&#xff0c;\u521d\u59cb\u5316\u76d1\u542c socket&#xff1b;<\/li>\n<li>Master fork \u51fa\u591a\u4e2a Worker \u8fdb\u7a0b&#xff1b;<\/li>\n<li>Worker \u8fdb\u7a0b\u7ade\u4e89\u65b0\u8fde\u63a5&#xff0c;\u83b7\u80dc\u65b9\u901a\u8fc7 TCP \u4e09\u6b21\u63e1\u624b\u5efa\u7acb\u8fde\u63a5&#xff0c;\u5904\u7406\u8bf7\u6c42\u3002<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"412\" src=\"2026-02-24fztuxpjprc1.png\" width=\"878\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"527\" src=\"2026-02-24dbuvc3ap3n4.png\" width=\"928\" \/><\/li>\n<h4>2.4 Nginx \u6a21\u5757\u4f53\u7cfb<\/h4>\n<p>Nginx \u9ad8\u5ea6\u6a21\u5757\u5316&#xff0c;\u6a21\u5757\u662f\u529f\u80fd\u5b9e\u73b0\u7684\u6838\u5fc3&#xff0c;1.9.11 \u7248\u672c\u5f00\u59cb\u652f\u6301\u52a8\u6001\u88c5\u8f7d \/ \u5378\u8f7d&#xff0c;\u6a21\u5757\u5206\u4e3a\u4e94\u5927\u7c7b&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"677\" src=\"2026-02-24ejt4bi3l0k3.png\" width=\"985\" \/><\/p>\n<table>\n<tr>\u6a21\u5757\u7c7b\u578b\u6838\u5fc3\u529f\u80fd\u793a\u4f8b<\/tr>\n<tbody>\n<tr>\n<td>\u6838\u5fc3\u6a21\u5757<\/td>\n<td>Nginx \u8fd0\u884c\u5fc5\u5907&#xff0c;\u8d1f\u8d23\u57fa\u7840\u529f\u80fd<\/td>\n<td>\u9519\u8bef\u65e5\u5fd7\u3001\u914d\u7f6e\u89e3\u6790\u3001\u4e8b\u4ef6\u9a71\u52a8\u3001\u8fdb\u7a0b\u7ba1\u7406<\/td>\n<\/tr>\n<tr>\n<td>\u6807\u51c6 HTTP \u6a21\u5757<\/td>\n<td>HTTP \u534f\u8bae\u89e3\u6790&#xff0c;\u57fa\u7840 Web \u529f\u80fd<\/td>\n<td>\u7aef\u53e3\u914d\u7f6e\u3001\u7f51\u9875\u7f16\u7801\u3001HTTP \u54cd\u5e94\u5934\u8bbe\u7f6e<\/td>\n<\/tr>\n<tr>\n<td>\u53ef\u9009 HTTP \u6a21\u5757<\/td>\n<td>\u6269\u5c55 HTTP \u529f\u80fd&#xff0c;\u9700\u7f16\u8bd1\u6307\u5b9a<\/td>\n<td>Gzip \u538b\u7f29\u3001SSL\u3001GeoIP \u89e3\u6790\u3001Flash \u4f20\u8f93<\/td>\n<\/tr>\n<tr>\n<td>\u90ae\u4ef6\u670d\u52a1\u6a21\u5757<\/td>\n<td>\u652f\u6301\u90ae\u4ef6\u4ee3\u7406\u534f\u8bae<\/td>\n<td>POP3\u3001IMAP\u3001SMTP \u534f\u8bae\u5904\u7406<\/td>\n<\/tr>\n<tr>\n<td>Stream \u670d\u52a1\u6a21\u5757<\/td>\n<td>\u5b9e\u73b0 TCP\/UDP \u53cd\u5411\u4ee3\u7406<\/td>\n<td>\u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u3001TCP \u534f\u8bae\u8f6c\u53d1<\/td>\n<\/tr>\n<tr>\n<td>\u7b2c\u4e09\u65b9\u6a21\u5757<\/td>\n<td>\u5f00\u53d1\u8005\u81ea\u5b9a\u4e49\u529f\u80fd<\/td>\n<td>Lua \u652f\u6301\u3001Json \u89e3\u6790\u3001Rds-json<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2.5 Nginx \u5b89\u88c5<\/h4>\n<p>\u63a8\u8350\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5&#xff08;\u53ef\u81ea\u5b9a\u4e49\u8def\u5f84\u3001\u529f\u80fd&#xff0c;yum \u7248\u672c\u8f83\u65e7&#xff09;&#xff0c;\u9700\u63d0\u524d\u5b89\u88c5\u4f9d\u8d56\u5e93&#xff0c;\u7f16\u8bd1\u540e\u751f\u6210\u56db\u5927\u6838\u5fc3\u76ee\u5f55\u3002<\/p>\n<h5>2.5.1 \u7f16\u8bd1\u5b89\u88c5\u51c6\u5907<\/h5>\n<li>\u4f9d\u8d56\u5e93&#xff1a;GCC&#xff08;\u7f16\u8bd1\u5668&#xff09;\u3001pcre-devel&#xff08;rewrite \u529f\u80fd&#xff09;\u3001zlib-devel&#xff08;gzip \u529f\u80fd&#xff09;\u3001openssl-devel&#xff08;SSL \u529f\u80fd&#xff09;\u3001Automake&#xff08;\u81ea\u52a8\u751f\u6210 Makefile&#xff09;&#xff1b;<\/li>\n<li>\u6e90\u7801\u4e0b\u8f7d&#xff1a;https:\/\/nginx.org\/en\/download.html&#xff1b;<\/li>\n<li>\u521b\u5efa\u8fd0\u884c\u7528\u6237&#xff1a;useradd -s \/sbin\/nologin -M nginx\u3002<\/li>\n<h5>2.5.2 \u7f16\u8bd1\u5b89\u88c5\u6b65\u9aa4<\/h5>\n<p># \u5b89\u88c5\u4f9d\u8d56<br \/>\ndnf install gcc pcre-devel zlib-devel openssl-devel -y<br \/>\n# \u89e3\u538b\u6e90\u7801<br \/>\ntar zxf nginx-1.24.0.tar.gz &amp;&amp; cd nginx-1.24.0<br \/>\n# \u914d\u7f6e\u7f16\u8bd1\u53c2\u6570&#xff08;\u81ea\u5b9a\u4e49\u8def\u5f84\u3001\u529f\u80fd&#xff09;<br \/>\n.\/configure &#8211;prefix&#061;\/usr\/local\/nginx \\\\<br \/>\n&#8211;user&#061;nginx &#8211;group&#061;nginx \\\\<br \/>\n&#8211;with-http_ssl_module &#8211;with-http_v2_module \\\\<br \/>\n&#8211;with-http_realip_module &#8211;with-http_stub_status_module \\\\<br \/>\n&#8211;with-http_gzip_static_module &#8211;with-pcre &#8211;with-stream<br \/>\n# \u7f16\u8bd1\u5e76\u5b89\u88c5<br \/>\nmake &amp;&amp; make install<\/p>\n<h5>2.5.3 \u6838\u5fc3\u76ee\u5f55\u8bf4\u660e<\/h5>\n<table>\n<tr>\u76ee\u5f55\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>\/usr\/local\/nginx\/conf<\/td>\n<td>\u6240\u6709\u914d\u7f6e\u6587\u4ef6&#xff0c;\u6838\u5fc3\u4e3a nginx.conf<\/td>\n<\/tr>\n<tr>\n<td>\/usr\/local\/nginx\/html<\/td>\n<td>\u9759\u6001 Web \u6587\u4ef6&#xff0c;\u5305\u542b\u9ed8\u8ba4\u9519\u8bef\u9875\u9762&#xff08;50x.html&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\/usr\/local\/nginx\/logs<\/td>\n<td>\u8bbf\u95ee\u65e5\u5fd7\u3001\u9519\u8bef\u65e5\u5fd7\u3001PID \u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>\/usr\/local\/nginx\/sbin<\/td>\n<td>\u4e8c\u8fdb\u5236\u542f\u52a8\u811a\u672c&#xff08;nginx&#xff09;&#xff0c;\u652f\u6301\u591a\u79cd\u547d\u4ee4\u53c2\u6570<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>2.5.4 Nginx \u5e38\u7528\u547d\u4ee4<\/h5>\n<p>nginx -v # \u67e5\u770b\u7248\u672c<br \/>\nnginx -V # \u67e5\u770b\u7248\u672c&#043;\u7f16\u8bd1\u53c2\u6570<br \/>\nnginx -t # \u6d4b\u8bd5\u914d\u7f6e\u6587\u4ef6\u6709\u6548\u6027<br \/>\nnginx -s reload # \u5e73\u6ed1\u91cd\u8f7d\u914d\u7f6e<br \/>\nnginx -s quit # \u4f18\u96c5\u9000\u51fa<br \/>\nnginx -s stop # \u5f3a\u5236\u505c\u6b62<br \/>\nnginx -g &#034;worker_processes 6;&#034; # \u4e34\u65f6\u6307\u5b9a\u5168\u5c40\u6307\u4ee4<\/p>\n<h5>2.5.5 \u7cfb\u7edf\u670d\u52a1\u914d\u7f6e&#xff08;systemd&#xff09;<\/h5>\n<p>\u521b\u5efa\/lib\/systemd\/system\/nginx.service&#xff0c;\u5b9e\u73b0 systemctl \u7ba1\u7406&#xff1a;<\/p>\n<p>[Unit]<br \/>\nDescription&#061;The NGINX HTTP and reverse proxy server<br \/>\nAfter&#061;syslog.target network-online.target remote-fs.target nss-lookup.target<br \/>\nWants&#061;network-online.target<br \/>\n[Service]<br \/>\nType&#061;forking<br \/>\nPIDFile&#061;\/usr\/local\/nginx\/logs\/nginx.pid<br \/>\nExecStartPre&#061;\/usr\/local\/nginx\/sbin\/nginx -t<br \/>\nExecStart&#061;\/usr\/local\/nginx\/sbin\/nginx<br \/>\nExecReload&#061;\/usr\/local\/nginx\/sbin\/nginx -s reload<br \/>\nExecStop&#061;\/bin\/kill -s QUIT $MAINPID<br \/>\nPrivateTmp&#061;true<br \/>\n[Install]<br \/>\nWantedBy&#061;multi-user.target<\/p>\n<p>\u542f\u7528\u670d\u52a1&#xff1a;systemctl daemon-reload &amp;&amp; systemctl enable &#8211;now nginx\u3002<\/p>\n<h4>2.6 Nginx \u5e73\u6ed1\u5347\u7ea7\u548c\u56de\u6eda<\/h4>\n<p>\u65e0\u9700\u505c\u673a&#xff0c;\u5b9e\u73b0\u7248\u672c\u5347\u7ea7 \/ \u56de\u6eda&#xff0c;\u6838\u5fc3\u901a\u8fc7\u4fe1\u53f7\u63a7\u5236&#xff08;SIGUSR2\u3001WINCH\u3001QUIT\u3001HUP&#xff09;&#xff0c;\u4fdd\u8bc1\u4e1a\u52a1\u4e0d\u4e2d\u65ad\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"722\" src=\"2026-02-24pgvgelce2me.png\" width=\"992\" \/><\/p>\n<h5>2.6.1 \u5e73\u6ed1\u5347\u7ea7\u6d41\u7a0b<\/h5>\n<li>\u5907\u4efd\u65e7\u7248 Nginx \u4e8c\u8fdb\u5236\u6587\u4ef6&#xff1a;cp \/usr\/local\/nginx\/sbin\/nginx \/usr\/local\/nginx\/sbin\/nginx.old&#xff1b;<\/li>\n<li>\u7f16\u8bd1\u65b0\u7248\u672c\u6e90\u7801&#xff08;\u4ec5 make&#xff0c;\u4e0d make install&#xff09;&#xff0c;\u5c06\u65b0\u4e8c\u8fdb\u5236\u6587\u4ef6\u66ff\u6362\u65e7\u6587\u4ef6&#xff1b;<\/li>\n<li>\u5411\u65e7 Master \u8fdb\u7a0b\u53d1\u9001SIGUSR2&#xff1a;\u65e7 Master \u91cd\u547d\u540d PID \u6587\u4ef6\u4e3a nginx.pid.oldbin&#xff0c;\u542f\u52a8\u65b0 Master \u8fdb\u7a0b&#xff1b;<\/li>\n<li>\u5411\u65e7 Master \u53d1\u9001WINCH&#xff1a;\u65e7 Worker \u8fdb\u7a0b\u5e73\u6ed1\u505c\u6b62&#xff0c;\u65b0\u8bf7\u6c42\u7531\u65b0 Worker \u5904\u7406&#xff1b;<\/li>\n<li>\u9a8c\u8bc1\u5347\u7ea7\u6210\u529f\u540e&#xff0c;\u5411\u65e7 Master \u53d1\u9001QUIT&#xff1a;\u5173\u95ed\u65e7 Master&#xff0c;\u5b8c\u6210\u5347\u7ea7\u3002<\/li>\n<h5>2.6.2 \u56de\u6eda\u6d41\u7a0b<\/h5>\n<li>\u5c06\u5907\u4efd\u7684\u65e7\u7248\u4e8c\u8fdb\u5236\u6587\u4ef6\u66ff\u6362\u65b0\u7248\u6587\u4ef6&#xff1b;<\/li>\n<li>\u5411\u65e7 Master&#xff08;nginx.pid.oldbin&#xff09;\u53d1\u9001HUP&#xff1a;\u91cd\u65b0\u62c9\u8d77\u65e7 Worker \u8fdb\u7a0b&#xff1b;<\/li>\n<li>\u5411\u65b0 Master \u53d1\u9001WINCH&#xff1a;\u65b0 Worker \u8fdb\u7a0b\u5e73\u6ed1\u505c\u6b62&#xff1b;<\/li>\n<li>\u5411\u65b0 Master \u53d1\u9001QUIT&#xff1a;\u5173\u95ed\u65b0 Master&#xff0c;\u5b8c\u6210\u56de\u6eda\u3002<\/li>\n<h3>\u4e09\u3001Nginx \u6838\u5fc3\u914d\u7f6e\u8be6\u89e3<\/h3>\n<p>Nginx \u914d\u7f6e\u6587\u4ef6\u4e3a\u7eaf\u6587\u672c\u683c\u5f0f&#xff0c;\u91c7\u7528\u6307\u4ee4 &#043; \u6307\u4ee4\u5757\u7ed3\u6784&#xff0c;\u652f\u6301 include \u5f15\u5165\u5b50\u914d\u7f6e\u3001\u6ce8\u91ca&#xff08;#&#xff09;\u3001\u53d8\u91cf&#xff08;$&#xff09;&#xff0c;\u6838\u5fc3\u5206\u4e3a\u56db\u5927\u914d\u7f6e\u6bb5&#xff1a;main&#xff08;\u5168\u5c40&#xff09;\u3001event&#xff08;\u4e8b\u4ef6\u9a71\u52a8&#xff09;\u3001http&#xff08;HTTP\/HTTPS&#xff09;\u3001stream&#xff08;TCP\/UDP&#xff09;&#xff0c;mail&#xff08;\u90ae\u4ef6&#xff09;\u4e3a\u53ef\u9009\u6bb5\u3002<\/p>\n<h4>3.1 \u914d\u7f6e\u6587\u4ef6\u57fa\u7840\u89c4\u5219<\/h4>\n<li>\u6307\u4ee4\u4ee5\u5206\u53f7&#xff1b; \u7ed3\u5c3e&#xff0c;\u6307\u4ee4\u4e0e\u503c\u4e4b\u95f4\u7528\u7a7a\u683c\u5206\u9694&#xff1b;<\/li>\n<li>\u6307\u4ee4\u5757\u4ee5 **{}** \u5305\u88f9&#xff0c;\u652f\u6301\u5d4c\u5957&#xff08;\u5982 http \u5305\u542b server&#xff0c;server \u5305\u542b location&#xff09;&#xff1b;<\/li>\n<li>include \u8bed\u53e5&#xff1a;\u7ec4\u5408\u591a\u4e2a\u914d\u7f6e\u6587\u4ef6&#xff0c;\u63d0\u5347\u53ef\u7ef4\u62a4\u6027&#xff08;\u5982include conf.d\/*.conf&#xff09;&#xff1b;<\/li>\n<li>\u53d8\u91cf&#xff1a;\u5185\u7f6e\u53d8\u91cf&#xff08;\u6a21\u5757\u63d0\u4f9b&#xff0c;\u76f4\u63a5\u4f7f\u7528&#xff09;\u3001\u81ea\u5b9a\u4e49\u53d8\u91cf&#xff08;set $\u53d8\u91cf\u540d \u503c;&#xff09;&#xff0c;\u5f15\u7528\u65b9\u5f0f\u4e3a$\u53d8\u91cf\u540d&#xff1b;<\/li>\n<li>\u90e8\u5206\u6307\u4ee4\u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f&#xff0c;\u7528\u4e8e URL \u5339\u914d\u3001\u6761\u4ef6\u5224\u65ad\u3002<\/li>\n<h4>3.2 \u5168\u5c40\u914d\u7f6e\u6bb5&#xff08;main&#xff09;<\/h4>\n<p>\u5bf9\u6240\u6709\u914d\u7f6e\u6bb5\u751f\u6548&#xff0c;\u6838\u5fc3\u4e3a Nginx \u8fd0\u884c\u7684\u57fa\u7840\u914d\u7f6e&#xff0c;\u5206\u4e3a\u5fc5\u5907\u914d\u7f6e\u3001\u6027\u80fd\u4f18\u5316\u914d\u7f6e\u3001\u8c03\u8bd5\u914d\u7f6e\u4e09\u7c7b\u3002<\/p>\n<h5>3.2.1 \u6838\u5fc3\u914d\u7f6e\u6307\u4ee4<\/h5>\n<table>\n<tr>\u6307\u4ee4\u529f\u80fd\u63a8\u8350\u503c<\/tr>\n<tbody>\n<tr>\n<td>user nginx nginx;<\/td>\n<td>\u542f\u52a8 Worker \u8fdb\u7a0b\u7684\u7528\u6237\u548c\u7ec4<\/td>\n<td>\u4e13\u7528 nginx \u7528\u6237<\/td>\n<\/tr>\n<tr>\n<td>worker_processes n;<\/td>\n<td>Worker \u8fdb\u7a0b\u6570\u91cf<\/td>\n<td>\u7b49\u4e8e CPU \u6838\u5fc3\u6570&#xff08;\u6216 auto&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>worker_cpu_affinity \u63a9\u7801&#xff1b;<\/td>\n<td>\u5c06 Worker \u8fdb\u7a0b\u7ed1\u5b9a\u5230\u6307\u5b9a CPU \u6838\u5fc3<\/td>\n<td>\u5982 4 \u6838\u5fc3&#xff1a;0001 0010 0100 1000<\/td>\n<\/tr>\n<tr>\n<td>error_log \u8def\u5f84 \u7ea7\u522b&#xff1b;<\/td>\n<td>\u9519\u8bef\u65e5\u5fd7\u8def\u5f84\u4e0e\u7ea7\u522b<\/td>\n<td>\/usr\/local\/nginx\/logs\/error.log error<\/td>\n<\/tr>\n<tr>\n<td>pid \u8def\u5f84&#xff1b;<\/td>\n<td>PID \u6587\u4ef6\u4fdd\u5b58\u8def\u5f84<\/td>\n<td>\/usr\/local\/nginx\/logs\/nginx.pid<\/td>\n<\/tr>\n<tr>\n<td>worker_priority n;<\/td>\n<td>Worker \u8fdb\u7a0b\u4f18\u5148\u7ea7<\/td>\n<td>0&#xff08;\u8303\u56f4 &#8211; 20~20&#xff0c;\u503c\u8d8a\u9ad8\u4f18\u5148\u7ea7\u8d8a\u9ad8&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>worker_rlimit_nofile n;<\/td>\n<td>Worker \u8fdb\u7a0b\u6700\u5927\u6253\u5f00\u6587\u4ef6\u6570<\/td>\n<td>65536&#xff08;\u4e0e\u7cfb\u7edf ulimit -n \u4e00\u81f4&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>daemon on\/off;<\/td>\n<td>\u662f\u5426\u4ee5\u5b88\u62a4\u8fdb\u7a0b\u8fd0\u884c<\/td>\n<td>on&#xff08;\u751f\u4ea7&#xff09;\/off&#xff08;\u6d4b\u8bd5 \/ \u5bb9\u5668&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>master_process on\/off;<\/td>\n<td>\u662f\u5426\u542f\u7528 Master-Worker \u6a21\u578b<\/td>\n<td>on&#xff08;\u751f\u4ea7&#xff09;\/off&#xff08;\u8c03\u8bd5&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>3.3 \u4e8b\u4ef6\u9a71\u52a8\u914d\u7f6e\u6bb5&#xff08;event&#xff09;<\/h4>\n<p>\u4ec5\u7528\u4e8e\u914d\u7f6e\u4e8b\u4ef6\u9a71\u52a8\u76f8\u5173\u529f\u80fd&#xff0c;\u51b3\u5b9a Nginx \u4e0e\u5ba2\u6237\u7aef\u7684\u7f51\u7edc\u8fde\u63a5\u65b9\u5f0f&#xff0c;\u662f\u9ad8\u5e76\u53d1\u4f18\u5316\u7684\u6838\u5fc3\u914d\u7f6e\u6bb5\u3002<\/p>\n<h5>3.3.1 \u6838\u5fc3\u914d\u7f6e\u6307\u4ee4<\/h5>\n<table>\n<tr>\u6307\u4ee4\u529f\u80fd\u63a8\u8350\u503c<\/tr>\n<tbody>\n<tr>\n<td>worker_connections n;<\/td>\n<td>\u5355\u4e2a Worker \u8fdb\u7a0b\u6700\u5927\u5e76\u53d1\u8fde\u63a5\u6570<\/td>\n<td>65535<\/td>\n<\/tr>\n<tr>\n<td>use \u6a21\u578b&#xff1b;<\/td>\n<td>\u4e8b\u4ef6\u9a71\u52a8\u6a21\u578b<\/td>\n<td>epoll&#xff08;Linux&#xff09;\/kqueue&#xff08;FreeBSD&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>accept_mutex on\/off;<\/td>\n<td>\u8fde\u63a5\u4e92\u65a5\u9501&#xff0c;\u9632\u6b62\u60ca\u7fa4\u6548\u5e94<\/td>\n<td>on<\/td>\n<\/tr>\n<tr>\n<td>multi_accept on\/off;<\/td>\n<td>\u5355\u4e2a Worker \u8fdb\u7a0b\u662f\u5426\u540c\u65f6\u63a5\u53d7\u591a\u4e2a\u8fde\u63a5<\/td>\n<td>on<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>3.3.2 \u9ad8\u5e76\u53d1\u914d\u7f6e\u8981\u70b9<\/h5>\n<li>\u8c03\u6574\u7cfb\u7edf\u5185\u6838&#xff1a;ulimit -n 65536&#xff08;\u4e34\u65f6&#xff09;&#xff0c;\u4fee\u6539\/etc\/security\/limits.conf&#xff08;\u6c38\u4e45&#xff09;&#xff1b;<\/li>\n<li>\u914d\u7f6eworker_rlimit_nofile 65536&#xff1a;\u7a81\u7834\u6587\u4ef6\u6570\u9650\u5236&#xff1b;<\/li>\n<li>\u5173\u95ed\u4e0d\u5fc5\u8981\u7684\u6a21\u5757&#xff0c;\u51cf\u5c11\u8d44\u6e90\u5360\u7528&#xff1b;<\/li>\n<li>\u5f00\u542fepoll\u3001accept_mutex\u3001multi_accept\u3002<\/li>\n<h4>3.4 HTTP \u914d\u7f6e\u6bb5&#xff08;http&#xff09;<\/h4>\n<p>\u5904\u7406\u6240\u6709 HTTP\/HTTPS \u534f\u8bae\u76f8\u5173\u914d\u7f6e&#xff0c;\u662f Nginx \u914d\u7f6e\u7684\u6838\u5fc3&#xff0c;\u5305\u542b\u865a\u62df\u4e3b\u673a\u3001\u7f13\u5b58\u3001\u4ee3\u7406\u3001\u65e5\u5fd7\u3001\u538b\u7f29\u7b49\u529f\u80fd&#xff0c;\u53ef\u5d4c\u5957\u591a\u4e2aserver\u6307\u4ee4\u5757&#xff08;\u865a\u62df\u4e3b\u673a&#xff09;\u3002<\/p>\n<h5>3.4.1 \u6838\u5fc3\u57fa\u7840\u914d\u7f6e\u6307\u4ee4<\/h5>\n<table>\n<tr>\u6307\u4ee4\u529f\u80fd\u63a8\u8350\u503c<\/tr>\n<tbody>\n<tr>\n<td>include mime.types;<\/td>\n<td>\u5f15\u5165 MIME \u7c7b\u578b\u6620\u5c04\u6587\u4ef6<\/td>\n<td>\u5fc5\u52a0<\/td>\n<\/tr>\n<tr>\n<td>default_type \u7c7b\u578b&#xff1b;<\/td>\n<td>\u672a\u5339\u914d MIME \u7c7b\u578b\u7684\u9ed8\u8ba4\u6587\u4ef6\u7c7b\u578b<\/td>\n<td>application\/octet-stream&#xff08;\u4e0b\u8f7d&#xff09;\/text\/html<\/td>\n<\/tr>\n<tr>\n<td>sendfile on\/off;<\/td>\n<td>\u542f\u7528\u96f6\u62f7\u8d1d SENDFILE \u6280\u672f<\/td>\n<td>on<\/td>\n<\/tr>\n<tr>\n<td>keepalive_timeout n [m];<\/td>\n<td>keep-alive \u957f\u8fde\u63a5\u8d85\u65f6\u65f6\u95f4<\/td>\n<td>65 60&#xff08;\u670d\u52a1\u5668 65s&#xff0c;\u544a\u77e5\u5ba2\u6237\u7aef 60s&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>keepalive_requests n;<\/td>\n<td>\u5355\u6761\u957f\u8fde\u63a5\u6700\u5927\u8bf7\u6c42\u6570<\/td>\n<td>500&#xff08;\u9ed8\u8ba4 100&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>log_format \u540d\u79f0 \u683c\u5f0f&#xff1b;<\/td>\n<td>\u5b9a\u4e49\u8bbf\u95ee\u65e5\u5fd7\u683c\u5f0f<\/td>\n<td>\u5305\u542b\u3001request\u3001$status \u7b49<\/td>\n<\/tr>\n<tr>\n<td>access_log \u8def\u5f84 \u683c\u5f0f&#xff1b;<\/td>\n<td>\u8bbf\u95ee\u65e5\u5fd7\u8def\u5f84\u4e0e\u683c\u5f0f<\/td>\n<td>\/usr\/local\/nginx\/logs\/access.log main<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>3.5 \u865a\u62df\u4e3b\u673a\u914d\u7f6e\u6bb5&#xff08;server&#xff09;<\/h4>\n<p>\u5c5e\u4e8ehttp\u5b50\u914d\u7f6e\u6bb5&#xff0c;\u4e00\u4e2ahttp\u53ef\u5305\u542b\u591a\u4e2aserver&#xff0c;\u6bcf\u4e2aserver\u5bf9\u5e94\u4e00\u4e2a\u865a\u62df\u4e3b\u673a&#xff0c;\u901a\u8fc7listen&#xff08;\u7aef\u53e3&#xff09;\u3001server_name&#xff08;\u57df\u540d \/ IP&#xff09;\u533a\u5206&#xff0c;\u6838\u5fc3\u7528\u4e8e\u90e8\u7f72\u591a\u7ad9\u70b9\u3002<\/p>\n<h5>3.5.1 \u6838\u5fc3\u914d\u7f6e\u6307\u4ee4<\/h5>\n<p>server {<br \/>\n    listen 80; # \u76d1\u542c\u7aef\u53e3&#xff08;\u53ef\u52a0IP&#xff0c;\u5982192.168.1.100:80&#xff09;<br \/>\n    server_name lee.timinglee.org www.timinglee.org; # \u865a\u62df\u4e3b\u673a\u57df\u540d&#xff0c;\u652f\u6301\u591a\u4e2a\u3001\u901a\u914d\u7b26\u3001\u6b63\u5219<br \/>\n    root \/webdata\/nginx\/timinglee.org\/html; # \u7ad9\u70b9\u6839\u76ee\u5f55<br \/>\n    index index.html index.htm index.php; # \u9ed8\u8ba4\u9996\u9875\u6587\u4ef6<br \/>\n    error_page 404 500 502 \/error.html; # \u81ea\u5b9a\u4e49\u9519\u8bef\u9875\u9762<br \/>\n    access_log \/var\/log\/nginx\/timinglee.access.log main; # \u72ec\u7acb\u8bbf\u95ee\u65e5\u5fd7<br \/>\n}<\/p>\n<h4>3.6 \u8def\u5f84\u5339\u914d\u914d\u7f6e\u6bb5&#xff08;location&#xff09;<\/h4>\n<p>\u5c5e\u4e8eserver\u5b50\u914d\u7f6e\u6bb5&#xff0c;\u4e00\u4e2aserver\u53ef\u5305\u542b\u591a\u4e2alocation&#xff0c;\u6839\u636e\u7528\u6237\u8bf7\u6c42\u7684 URI\u8fdb\u884c\u5339\u914d&#xff0c;\u5b9e\u73b0\u8def\u5f84\u6620\u5c04\u3001\u8bbf\u95ee\u63a7\u5236\u3001\u53cd\u5411\u4ee3\u7406\u7b49\u529f\u80fd&#xff0c;\u662f Nginx \u914d\u7f6e\u6700\u7075\u6d3b\u7684\u90e8\u5206\u3002<\/p>\n<h5>3.6.1 location \u5339\u914d\u8bed\u6cd5\u4e0e\u4f18\u5148\u7ea7<\/h5>\n<p>\u8bed\u6cd5&#xff1a;location [ &#061; | ~ | ~* | ^~ ] uri { &#8230; }\u5339\u914d\u4f18\u5148\u7ea7\u4ece\u9ad8\u5230\u4f4e&#xff1a;&#061;&#xff08;\u7cbe\u786e\u5339\u914d&#xff09; &gt; ^~&#xff08;\u524d\u7f00\u5339\u914d&#xff0c;\u7ec8\u6b62\u6b63\u5219&#xff09; &gt; ~&#xff08;\u6b63\u5219&#xff0c;\u533a\u5206\u5927\u5c0f\u5199&#xff09;\/~*&#xff08;\u6b63\u5219&#xff0c;\u4e0d\u533a\u5206\u5927\u5c0f\u5199&#xff09; &gt; \u666e\u901a\u524d\u7f00\u5339\u914d&#xff08;\u65e0\u7b26\u53f7&#xff09;<\/p>\n<table>\n<tr>\u4fee\u9970\u7b26\u529f\u80fd\u793a\u4f8b<\/tr>\n<tbody>\n<tr>\n<td>&#061;<\/td>\n<td>\u7cbe\u786e\u5339\u914d URI&#xff0c;\u5339\u914d\u6210\u529f\u7acb\u5373\u505c\u6b62<\/td>\n<td>location &#061; \/logo.png { &#8230; }<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>^~<\/td>\n<td>\u524d\u7f00\u5339\u914d&#xff0c;\u5339\u914d\u6210\u529f\u540e\u7ec8\u6b62\u540e\u7eed\u6b63\u5219\u5339\u914d<\/td>\n<td>location ^~ \/static\/ { &#8230; }<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>~<\/td>\n<td>\u6b63\u5219\u5339\u914d&#xff0c;\u533a\u5206\u5927\u5c0f\u5199<\/td>\n<td>location ~ .php$ { &#8230; }<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>~*<\/td>\n<td>\u6b63\u5219\u5339\u914d&#xff0c;\u4e0d\u533a\u5206\u5927\u5c0f\u5199<\/td>\n<td>location ~* .(jpg<\/td>\n<td>png<\/td>\n<td>gif)$ { &#8230; }<\/td>\n<\/tr>\n<tr>\n<td>\u65e0<\/td>\n<td>\u666e\u901a\u524d\u7f00\u5339\u914d&#xff0c;\u6309\u5339\u914d\u5ea6\u6700\u9ad8\u5339\u914d<\/td>\n<td>location \/web\/ { &#8230; }<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>3.6.2 root \u4e0e alias&#xff08;\u8def\u5f84\u6620\u5c04&#xff09;<\/h5>\n<p>\u5747\u7528\u4e8e\u6307\u5b9a\u6587\u4ef6\u8def\u5f84&#xff0c;\u6838\u5fc3\u533a\u522b&#xff1a;<\/p>\n<li>root&#xff1a;root \u8def\u5f84&#xff0c;\u6587\u4ef6\u7edd\u5bf9\u8def\u5f84 &#061; root \u8def\u5f84 &#043; location URI&#xff08;\u9ed8\u8ba4\u65b9\u5f0f&#xff09;&#xff1b;\u793a\u4f8b&#xff1a;location \/dirtest { root \/mnt; } \u2192 \u8bbf\u95ee\/dirtest\u5bf9\u5e94\/mnt\/dirtest&#xff1b;<\/li>\n<li>alias&#xff1a;alias \u8def\u5f84&#xff0c;\u76f4\u63a5\u66ff\u6362 location URI \u4e3a\u6307\u5b9a\u8def\u5f84&#xff0c;\u4ec5\u9002\u7528\u4e8e location&#xff1b;\u793a\u4f8b&#xff1a;location \/alias { alias \/mnt\/dirtest; } \u2192 \u8bbf\u95ee\/alias\u5bf9\u5e94\/mnt\/dirtest\u3002<\/li>\n<h4>3.7 \u6838\u5fc3\u914d\u7f6e\u5b9e\u6218\u6848\u4f8b<\/h4>\n<h5>3.7.1 \u591a\u865a\u62df\u4e3b\u673a\u914d\u7f6e<\/h5>\n<p>\u57fa\u4e8e\u57df\u540d\u90e8\u7f72\u4e24\u4e2a\u7ad9\u70b9&#xff0c;\u901a\u8fc7 include \u5f15\u5165\u5b50\u914d\u7f6e&#xff1a;<\/p>\n<p># \u521b\u5efa\u5b50\u914d\u7f6e\u76ee\u5f55<br \/>\nmkdir \/usr\/local\/nginx\/conf.d<br \/>\n# \u4e3b\u914d\u7f6e\u6587\u4ef6\u5f15\u5165\u5b50\u914d\u7f6e<br \/>\necho &#039;include conf.d\/*.conf;&#039; &gt;&gt; \/usr\/local\/nginx\/conf\/nginx.conf<br \/>\n# \u521b\u5efa\u7ad9\u70b9\u914d\u7f6e\u6587\u4ef6<br \/>\nvim \/usr\/local\/nginx\/conf.d\/lee.conf<br \/>\nserver {<br \/>\n    listen 80;<br \/>\n    server_name lee.timinglee.org;<br \/>\n    root \/webdata\/nginx\/lee\/html;<br \/>\n    index index.html;<br \/>\n}<br \/>\nvim \/usr\/local\/nginx\/conf.d\/www.conf<br \/>\nserver {<br \/>\n    listen 80;<br \/>\n    server_name www.timinglee.org;<br \/>\n    root \/webdata\/nginx\/www\/html;<br \/>\n    index index.html;<br \/>\n}<\/p>\n<h5>3.7.2 \u81ea\u5b9a\u4e49\u9519\u8bef\u9875\u9762<\/h5>\n<p>server {<br \/>\n    listen 80;<br \/>\n    server_name lee.timinglee.org;<br \/>\n    root \/webdata\/nginx\/lee\/html;<br \/>\n    error_page 404 \/404.html; # 404\u9519\u8bef\u6307\u5411404.html<br \/>\n    error_page 500 502 503 504 \/50x.html; # \u670d\u52a1\u5668\u9519\u8bef\u6307\u541150x.html<br \/>\n    # \u9519\u8bef\u9875\u9762\u72ec\u7acb\u8def\u5f84<br \/>\n    location &#061; \/404.html {<br \/>\n        root \/webdata\/nginx\/lee\/errors;<br \/>\n    }<br \/>\n    location &#061; \/50x.html {<br \/>\n        root \/webdata\/nginx\/lee\/errors;<br \/>\n    }<br \/>\n}<\/p>\n<h5>3.7.3 \u6587\u4ef6\u5b58\u5728\u68c0\u6d4b&#xff08;try_files&#xff09;<\/h5>\n<p>\u6309\u987a\u5e8f\u68c0\u67e5\u6587\u4ef6 \/ \u76ee\u5f55\u662f\u5426\u5b58\u5728&#xff0c;\u8fd4\u56de\u7b2c\u4e00\u4e2a\u5b58\u5728\u7684&#xff0c;\u5426\u5219\u91cd\u5b9a\u5411\u81f3\u6700\u540e\u4e00\u4e2a\u53c2\u6570&#xff1a;<\/p>\n<p>server {<br \/>\n    listen 80;<br \/>\n    server_name lee.timinglee.org;<br \/>\n    root \/webdata\/nginx\/lee\/html;<br \/>\n    # \u68c0\u67e5$uri \u2192 $uri.html \u2192 $uri\/index.html&#xff0c;\u5747\u4e0d\u5b58\u5728\u5219\u6307\u5411\/error\/default.html<br \/>\n    try_files $uri $uri.html $uri\/index.html \/error\/default.html;<br \/>\n}<\/p>\n<h5>3.7.4 \u4e0b\u8f7d\u670d\u52a1\u5668\u914d\u7f6e&#xff08;autoindex&#xff09;<\/h5>\n<p>\u542f\u7528\u81ea\u52a8\u76ee\u5f55\u7d22\u5f15&#xff0c;\u652f\u6301\u6587\u4ef6\u4e0b\u8f7d&#xff0c;\u53ef\u9650\u901f\u3001\u663e\u793a\u6587\u4ef6\u4fe1\u606f&#xff1a;<\/p>\n<p>server {<br \/>\n    listen 80;<br \/>\n    server_name lee.timinglee.org;<br \/>\n    root \/webdata\/nginx\/lee;<br \/>\n    location \/download {<br \/>\n        autoindex on; # \u542f\u7528\u81ea\u52a8\u7d22\u5f15<br \/>\n        autoindex_exact_size off; # \u663e\u793a\u6587\u4ef6\u8fd1\u4f3c\u5927\u5c0f&#xff08;K\/M\/G&#xff09;<br \/>\n        autoindex_localtime on; # \u663e\u793a\u670d\u52a1\u5668\u672c\u5730\u65f6\u95f4<br \/>\n        limit_rate 1024k; # \u9650\u901f1MB\/s<br \/>\n    }<br \/>\n}<\/p>\n<h5>3.7.5 \u8d26\u6237\u8ba4\u8bc1&#xff08;auth_basic&#xff09;<\/h5>\n<p>\u57fa\u4e8engx_http_auth_basic_module\u5b9e\u73b0 HTTP \u57fa\u672c\u8ba4\u8bc1&#xff0c;\u9700\u751f\u6210\u5bc6\u7801\u6587\u4ef6&#xff1a;<\/p>\n<p># \u5b89\u88c5htpasswd&#xff0c;\u751f\u6210\u5bc6\u7801\u6587\u4ef6<br \/>\nyum install httpd-tools -y<br \/>\nhtpasswd -cmb \/usr\/local\/nginx\/conf\/.htpasswd admin 123456<\/p>\n<p>location \/admin {<br \/>\n    root \/webdata\/nginx\/lee\/html;<br \/>\n    auth_basic &#034;Admin Login&#034;; # \u8ba4\u8bc1\u63d0\u793a\u8bed<br \/>\n    auth_basic_user_file \/usr\/local\/nginx\/conf\/.htpasswd; # \u5bc6\u7801\u6587\u4ef6\u8def\u5f84<br \/>\n}<\/p>\n<h3>\u56db\u3001Nginx \u9ad8\u7ea7\u914d\u7f6e<\/h3>\n<h4>4.1 Nginx \u72b6\u6001\u9875&#xff08;stub_status&#xff09;<\/h4>\n<p>\u57fa\u4e8engx_http_stub_status_module\u5b9e\u73b0&#xff0c;\u67e5\u770b Nginx \u8fd0\u884c\u72b6\u6001&#xff08;\u9700\u7f16\u8bd1\u65f6\u6dfb\u52a0&#8211;with-http_stub_status_module&#xff09;&#xff0c;\u663e\u793a\u5168\u5c40\u72b6\u6001&#xff0c;\u975e\u5355\u4e2a\u865a\u62df\u4e3b\u673a\u3002<\/p>\n<h5>4.1.1 \u914d\u7f6e\u793a\u4f8b<\/h5>\n<p>location \/nginx_status {<br \/>\n    stub_status; # \u542f\u7528\u72b6\u6001\u9875<br \/>\n    auth_basic &#034;Nginx Status&#034;; # \u8ba4\u8bc1\u4fdd\u62a4<br \/>\n    auth_basic_user_file \/usr\/local\/nginx\/conf\/.htpasswd;<br \/>\n    allow 192.168.1.0\/24; # \u5141\u8bb8\u6307\u5b9aIP\u6bb5\u8bbf\u95ee<br \/>\n    allow 127.0.0.1;<br \/>\n    deny all; # \u62d2\u7edd\u5176\u4ed6IP<br \/>\n}<\/p>\n<h5>4.1.2 \u72b6\u6001\u9875\u6838\u5fc3\u6307\u6807<\/h5>\n<p>Active connections: 291 # \u5f53\u524d\u6d3b\u52a8\u8fde\u63a5\u6570&#xff08;Reading&#043;Writing&#043;Waiting&#xff09;<br \/>\nserver accepts handled requests<br \/>\n 16630948 16630948 31070465 # \u63a5\u53d7\u8fde\u63a5\u6570\/\u5904\u7406\u8fde\u63a5\u6570\/\u603b\u8bf7\u6c42\u6570<br \/>\nReading: 6 Writing: 179 Waiting: 106 # \u8bfb\u53d6\u8bf7\u6c42\/\u53d1\u9001\u54cd\u5e94\/\u7a7a\u95f2\u7b49\u5f85\u8fde\u63a5\u6570<\/p>\n<ul>\n<li>Waiting&#xff1a;\u5f00\u542f keep-alive \u65f6\u7684\u7a7a\u95f2\u8fde\u63a5\u6570&#xff0c;Waiting &#061; Active &#8211; (Reading&#043;Writing)&#xff1b;<\/li>\n<li>handled&#xff1a;\u4e00\u822c\u7b49\u4e8e accepts&#xff0c;\u9664\u975e\u56e0worker_connections\u9650\u5236\u88ab\u62d2\u7edd\u3002<\/li>\n<\/ul>\n<h4>4.2 Nginx \u538b\u7f29\u529f\u80fd&#xff08;gzip&#xff09;<\/h4>\n<p>\u57fa\u4e8engx_http_gzip_module\u5b9e\u73b0&#xff0c;\u5bf9\u6307\u5b9a\u7c7b\u578b\u6587\u4ef6\u538b\u7f29\u540e\u4f20\u8f93&#xff0c;\u964d\u4f4e\u5e26\u5bbd\u6d88\u8017&#xff08;\u9700\u6d88\u8017\u5c11\u91cf CPU&#xff09;&#xff0c;\u9ed8\u8ba4\u5185\u7f6e\u6a21\u5757&#xff0c;\u65e0\u9700\u989d\u5916\u7f16\u8bd1\u3002<\/p>\n<h5>4.2.1 \u6838\u5fc3\u914d\u7f6e\u6307\u4ee4<\/h5>\n<p>http {<br \/>\n    gzip on; # \u542f\u7528gzip\u538b\u7f29<br \/>\n    gzip_comp_level 5; # \u538b\u7f29\u7ea7\u522b1-9&#xff0c;5\u4e3a\u5e73\u8861\u503c&#xff08;\u503c\u8d8a\u9ad8\u538b\u7f29\u6bd4\u8d8a\u9ad8&#xff0c;CPU\u6d88\u8017\u8d8a\u5927&#xff09;<br \/>\n    gzip_min_length 1k; # \u6700\u5c0f\u538b\u7f29\u6587\u4ef6\u5927\u5c0f&#xff0c;\u5c0f\u4e8e1k\u4e0d\u538b\u7f29<br \/>\n    gzip_types text\/plain text\/html text\/css application\/javascript application\/json image\/png; # \u538b\u7f29\u7684\u6587\u4ef6\u7c7b\u578b<br \/>\n    gzip_vary on; # \u54cd\u5e94\u5934\u6dfb\u52a0Vary: Accept-Encoding&#xff0c;\u544a\u77e5\u6d4f\u89c8\u5668\u652f\u6301\u538b\u7f29<br \/>\n    gzip_disable &#034;MSIE [1-6]\\\\.&#034;; # \u7981\u7528IE6\u53ca\u4ee5\u4e0b\u538b\u7f29&#xff08;\u4e0d\u652f\u6301&#xff09;<br \/>\n    gzip_static on; # \u542f\u7528\u9884\u538b\u7f29&#xff08;\u76f4\u63a5\u4f7f\u7528.gz\u6587\u4ef6&#xff0c;\u65e0\u9700\u5b9e\u65f6\u538b\u7f29&#xff09;<br \/>\n}<\/p>\n<h5>4.2.2 \u9a8c\u8bc1\u538b\u7f29<\/h5>\n<p>\u4f7f\u7528 curl \u547d\u4ee4\u9a8c\u8bc1&#xff0c;\u54cd\u5e94\u5934\u5305\u542bContent-Encoding: gzip\u5373\u4e3a\u538b\u7f29\u6210\u529f&#xff1a;<\/p>\n<p>curl &#8211;head &#8211;compressed http:\/\/lee.timinglee.org\/data.txt<\/p>\n<h4>4.3 Nginx \u7248\u672c\u9690\u85cf<\/h4>\n<p>\u9690\u85cf\u54cd\u5e94\u5934\u4e2d\u7684 Nginx \u7248\u672c\u53f7&#xff0c;\u63d0\u5347\u5b89\u5168\u6027&#xff0c;\u9700\u4fee\u6539\u6e90\u7801\u91cd\u65b0\u7f16\u8bd1&#xff1a;<\/p>\n<p># \u7f16\u8f91\u6e90\u7801\u5934\u6587\u4ef6<br \/>\nvim nginx-1.26.1\/src\/core\/nginx.h<br \/>\n# \u4fee\u6539\u7248\u672c\u53f7<br \/>\n#define NGINX_VERSION &#034;1.0&#034;<br \/>\n# \u53ef\u9009&#xff1a;\u4fee\u6539\u670d\u52a1\u5668\u6807\u8bc6<br \/>\n#define NGINX_VER &#034;HAHA\/&#034; NGINX_VERSION<br \/>\n# \u91cd\u65b0\u7f16\u8bd1\u5b89\u88c5<br \/>\nmake &amp;&amp; make install<\/p>\n<h4>4.4 Nginx \u53d8\u91cf\u4f7f\u7528<\/h4>\n<p>Nginx \u53d8\u91cf\u5206\u4e3a\u5185\u7f6e\u53d8\u91cf&#xff08;\u6a21\u5757\u63d0\u4f9b&#xff0c;\u83b7\u53d6\u8bf7\u6c42 \/ \u670d\u52a1\u5668\u4fe1\u606f&#xff09;\u548c\u81ea\u5b9a\u4e49\u53d8\u91cf&#xff08;\u7528\u6237\u5b9a\u4e49&#xff0c;set\u6307\u4ee4&#xff09;&#xff0c;\u7528\u4e8e\u914d\u7f6e\u5224\u65ad\u3001\u65e5\u5fd7\u3001URL \u91cd\u5199\u7b49\u573a\u666f\u3002<\/p>\n<h5>4.4.1 \u5e38\u7528\u5185\u7f6e\u53d8\u91cf<\/h5>\n<table>\n<tr>\u53d8\u91cf\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>$remote_addr<\/td>\n<td>\u5ba2\u6237\u7aef IP \u5730\u5740<\/td>\n<\/tr>\n<tr>\n<td>$request_uri<\/td>\n<td>\u5305\u542b\u53c2\u6570\u7684\u5b8c\u6574 URI&#xff08;\u5982 \/var?id&#061;1&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>$document_uri<\/td>\n<td>\u4e0d\u5305\u542b\u53c2\u6570\u7684 URI&#xff08;\u5982 \/var&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>$host<\/td>\n<td>\u5ba2\u6237\u7aef\u8bf7\u6c42\u7684\u4e3b\u673a\u540d<\/td>\n<\/tr>\n<tr>\n<td>$server_name<\/td>\n<td>\u865a\u62df\u4e3b\u673a\u540d<\/td>\n<\/tr>\n<tr>\n<td>$server_port<\/td>\n<td>\u76d1\u542c\u7aef\u53e3<\/td>\n<\/tr>\n<tr>\n<td>$http_user_agent<\/td>\n<td>\u5ba2\u6237\u7aef\u6d4f\u89c8\u5668\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td>$args<\/td>\n<td>URL \u4e2d\u7684\u6240\u6709\u53c2\u6570<\/td>\n<\/tr>\n<tr>\n<td>$scheme<\/td>\n<td>\u8bf7\u6c42\u534f\u8bae&#xff08;http\/https&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>4.4.2 \u81ea\u5b9a\u4e49\u53d8\u91cf<\/h5>\n<p>\u901a\u8fc7set $\u53d8\u91cf\u540d \u503c;\u5b9a\u4e49&#xff0c;\u652f\u6301\u62fc\u63a5\u5185\u7f6e\u53d8\u91cf&#xff1a;<\/p>\n<p>location \/var {<br \/>\n    default_type text\/html;<br \/>\n    set $name lee; # \u81ea\u5b9a\u4e49\u53d8\u91cf<br \/>\n    set $web_addr $scheme:\/\/$host:$server_port; # \u62fc\u63a5\u5185\u7f6e\u53d8\u91cf<br \/>\n    echo $name; # \u8f93\u51fa\u53d8\u91cf&#xff08;\u9700ngx_http_echo_module&#xff09;<br \/>\n    echo $web_addr;<br \/>\n}<\/p>\n<h4>4.5 Nginx Rewrite \u529f\u80fd<\/h4>\n<p>\u57fa\u4e8engx_http_rewrite_module\u5b9e\u73b0&#xff0c;\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d URI \u5e76\u4fee\u6539&#xff0c;\u652f\u6301 URL \u91cd\u5b9a\u5411\u3001\u5730\u5740\u4f2a\u88c5\u3001\u9632\u76d7\u94fe\u7b49&#xff0c;\u6838\u5fc3\u4f9d\u8d56 PCRE \u5e93&#xff08;\u7f16\u8bd1\u65f6\u9700&#8211;with-pcre&#xff09;\u3002<\/p>\n<h5>4.5.1 \u6838\u5fc3\u6307\u4ee4<\/h5>\n<li>if \u6307\u4ee4&#xff1a;\u6761\u4ef6\u5224\u65ad&#xff0c;\u652f\u6301\u6b63\u5219\u5339\u914d\u3001\u6587\u4ef6\u68c0\u6d4b&#xff0c;\u4e0d\u652f\u6301 else\/elif&#xff1b;\u793a\u4f8b&#xff1a;if ($scheme &#061; http) { rewrite ^(.*)$ https:\/\/$host$1 permanent; }&#xff1b;<\/li>\n<li>set \u6307\u4ee4&#xff1a;\u5b9a\u4e49\u53d8\u91cf&#xff0c;\u7528\u4e8e\u6761\u4ef6\u5224\u65ad\u548c Rewrite&#xff1b;<\/li>\n<li>break \u6307\u4ee4&#xff1a;\u4e2d\u65ad\u5f53\u524d location \u7684\u540e\u7eed Rewrite \u89c4\u5219&#xff0c;\u7ee7\u7eed\u6267\u884c\u5176\u4ed6\u6307\u4ee4&#xff1b;<\/li>\n<li>return \u6307\u4ee4&#xff1a;\u76f4\u63a5\u8fd4\u56de\u54cd\u5e94\u72b6\u6001\u7801 \/ \u91cd\u5b9a\u5411&#xff0c;\u540e\u7eed\u6307\u4ee4\u5168\u90e8\u4e0d\u6267\u884c&#xff1b;\u793a\u4f8b&#xff1a;return 301 http:\/\/www.baidu.com;&#xff08;\u6c38\u4e45\u91cd\u5b9a\u5411&#xff09;\u3001return 403 &#034;Forbidden&#034;;&#xff08;\u7981\u6b62\u8bbf\u95ee&#xff09;&#xff1b;<\/li>\n<li>rewrite \u6307\u4ee4&#xff1a;\u6838\u5fc3 Rewrite \u6307\u4ee4&#xff0c;\u8bed\u6cd5&#xff1a;rewrite regex replacement [flag];\u3002<\/li>\n<h5>4.5.2 Rewrite Flag&#xff08;\u6807\u5fd7\u4f4d&#xff09;<\/h5>\n<p>\u63a7\u5236 Rewrite \u7684\u5faa\u73af\u673a\u5236&#xff0c;\u5206\u4e3a\u8df3\u8f6c\u578b&#xff08;\u5ba2\u6237\u7aef\u91cd\u5b9a\u5411&#xff09;\u548c\u4ee3\u7406\u578b&#xff08;\u670d\u52a1\u5668\u5185\u90e8\u8df3\u8f6c&#xff09;&#xff1a;<\/p>\n<table>\n<tr>Flag\u7c7b\u578b\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>redirect<\/td>\n<td>\u8df3\u8f6c\u578b<\/td>\n<td>\u4e34\u65f6\u91cd\u5b9a\u5411&#xff08;302&#xff09;&#xff0c;\u5ba2\u6237\u7aef\u91cd\u65b0\u53d1\u8d77\u8bf7\u6c42&#xff0c;\u9002\u7528\u4e8e\u4e34\u65f6\u8c03\u6574<\/td>\n<\/tr>\n<tr>\n<td>permanent<\/td>\n<td>\u8df3\u8f6c\u578b<\/td>\n<td>\u6c38\u4e45\u91cd\u5b9a\u5411&#xff08;301&#xff09;&#xff0c;\u5ba2\u6237\u7aef\u7f13\u5b58\u91cd\u5b9a\u5411\u8bb0\u5f55&#xff0c;\u9002\u7528\u4e8e\u6c38\u4e45\u57df\u540d\u53d8\u66f4<\/td>\n<\/tr>\n<tr>\n<td>break<\/td>\n<td>\u4ee3\u7406\u578b<\/td>\n<td>\u505c\u6b62\u5f53\u524d location \u7684\u540e\u7eed Rewrite&#xff0c;\u76f4\u63a5\u6267\u884c\u540e\u7eed\u914d\u7f6e&#xff0c;\u7ed3\u675f\u5faa\u73af<\/td>\n<\/tr>\n<tr>\n<td>last<\/td>\n<td>\u4ee3\u7406\u578b<\/td>\n<td>\u505c\u6b62\u5f53\u524d location \u7684\u540e\u7eed Rewrite&#xff0c;\u5bf9\u65b0 URI \u542f\u52a8\u65b0\u4e00\u8f6e Rewrite \u68c0\u67e5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>4.5.3 Rewrite \u5b9e\u6218\u6848\u4f8b<\/h5>\n<li>\u57df\u540d\u6c38\u4e45\u91cd\u5b9a\u5411&#xff1a;\u5c06lee.timinglee.org\u6c38\u4e45\u91cd\u5b9a\u5411\u81f3www.timinglee.org&#xff1a; server {<br \/>\n    listen 80;<br \/>\n    server_name lee.timinglee.org;<br \/>\n    rewrite ^(.*)$ http:\/\/www.timinglee.org$1 permanent;<br \/>\n}\n <\/li>\n<li>HTTP \u81ea\u52a8\u8df3\u8f6c HTTPS&#xff1a;\u5168\u7ad9\u5f3a\u5236 HTTPS&#xff0c;\u907f\u514d\u6b7b\u5faa\u73af&#xff08;\u6dfb\u52a0 $scheme \u5224\u65ad&#xff09;&#xff1a; server {<br \/>\n    listen 80;<br \/>\n    listen 443 ssl;<br \/>\n    server_name www.timinglee.org;<br \/>\n    ssl_certificate \/usr\/local\/nginx\/certs\/cert.pem;<br \/>\n    ssl_certificate_key \/usr\/local\/nginx\/certs\/key.pem;<br \/>\n    if ($scheme &#061; http) {<br \/>\n        rewrite ^(.*)$ https:\/\/$host$1 redirect;<br \/>\n    }<br \/>\n    root \/webdata\/nginx\/www\/html;<br \/>\n}\n <\/li>\n<li>\u6587\u4ef6\u4e0d\u5b58\u5728\u91cd\u5b9a\u5411\u9996\u9875&#xff1a;\u8bbf\u95ee\u4e0d\u5b58\u5728\u7684 URL \u65f6&#xff0c;\u91cd\u5b9a\u5411\u81f3\u7f51\u7ad9\u9996\u9875&#xff1a; server {<br \/>\n    listen 80;<br \/>\n    server_name www.timinglee.org;<br \/>\n    root \/webdata\/nginx\/www\/html;<br \/>\n    if (!-e $request_filename) {<br \/>\n        rewrite .* \/index.html redirect;<br \/>\n    }<br \/>\n}\n <\/li>\n<h4>4.6 Nginx \u9632\u76d7\u94fe<\/h4>\n<p>\u57fa\u4e8engx_http_referer_module\u5b9e\u73b0&#xff0c;\u901a\u8fc7\u68c0\u67e5\u8bf7\u6c42\u5934\u7684Referer \u5b57\u6bb5&#xff08;\u8bb0\u5f55\u8bf7\u6c42\u6765\u6e90&#xff09;&#xff0c;\u963b\u6b62\u5176\u4ed6\u7f51\u7ad9\u76f4\u63a5\u94fe\u63a5\u672c\u7ad9\u8d44\u6e90&#xff08;\u56fe\u7247\u3001\u89c6\u9891\u3001\u6587\u4ef6\u7b49&#xff09;\u3002<\/p>\n<h5>4.6.1 Referer \u6709\u6548\u503c<\/h5>\n<table>\n<tr>\u7c7b\u578b\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>none<\/td>\n<td>\u65e0 Referer&#xff08;\u7528\u6237\u76f4\u63a5\u8f93\u5165\u57df\u540d\u8bbf\u95ee&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>blocked<\/td>\n<td>Referer \u65e0\u6709\u6548\u503c&#xff08;\u5982\u4e3a\u7a7a&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>server_names<\/td>\n<td>Referer \u5305\u542b\u672c\u7ad9\u57df\u540d&#xff08;$server_name&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u901a\u914d\u7b26<\/td>\n<td>\u81ea\u5b9a\u4e49\u57df\u540d&#xff0c;\u5982 *.timinglee.org<\/td>\n<\/tr>\n<tr>\n<td>\u6b63\u5219<\/td>\n<td>\u6b63\u5219\u5339\u914d Referer&#xff0c;\u5982&#xff5e;\/.baidu\/&#xff08;\u5141\u8bb8\u767e\u5ea6\u641c\u7d22&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>4.6.2 \u9632\u76d7\u94fe\u914d\u7f6e\u793a\u4f8b<\/h5>\n<p>server {<br \/>\n    listen 80;<br \/>\n    server_name www.timinglee.org;<br \/>\n    root \/webdata\/nginx\/www\/html;<br \/>\n    # \u5bf9\u56fe\u7247\u8d44\u6e90\u9632\u76d7\u94fe<br \/>\n    location ~* \\\\.(jpg|png|gif|jpeg)$ {<br \/>\n        # \u5141\u8bb8\u7684Referer<br \/>\n        valid_referers none blocked server_names *.timinglee.org ~\/.baidu\/ ~\/.google\/;<br \/>\n        # \u65e0\u6548Referer\u8fd4\u56de404\u6216\u91cd\u5b9a\u5411\u81f3\u9632\u76d7\u94fe\u56fe\u7247<br \/>\n        if ($invalid_referer) {<br \/>\n            # return 404;<br \/>\n            rewrite ^\/ http:\/\/www.timinglee.org\/daolian.png permanent;<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<h3>\u4e94\u3001Nginx \u53cd\u5411\u4ee3\u7406\u529f\u80fd<\/h3>\n<p>\u53cd\u5411\u4ee3\u7406\u662f Nginx \u7684\u6838\u5fc3\u529f\u80fd\u4e4b\u4e00&#xff0c;\u6307\u4ee3\u7406\u670d\u52a1\u5668\u63a5\u6536\u5ba2\u6237\u7aef\u8bf7\u6c42&#xff0c;\u8f6c\u53d1\u81f3\u540e\u7aef\u670d\u52a1\u5668\u5904\u7406&#xff0c;\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef&#xff0c;\u4ee3\u8868\u670d\u52a1\u7aef\u5229\u76ca&#xff0c;\u4e0e\u6b63\u5411\u4ee3\u7406&#xff08;\u4ee3\u8868\u5ba2\u6237\u7aef\u5229\u76ca&#xff0c;\u5982\u7ffb\u5899&#xff09;\u672c\u8d28\u533a\u522b\u3002<\/p>\n<p>Nginx \u652f\u6301\u4e03\u5c42\u53cd\u5411\u4ee3\u7406&#xff08;HTTP\/HTTPS&#xff0c;\u57fa\u4e8engx_http_proxy_module&#xff09;\u548c\u56db\u5c42\u53cd\u5411\u4ee3\u7406&#xff08;TCP\/UDP&#xff0c;\u57fa\u4e8engx_stream_proxy_module&#xff0c;1.9 &#043; \u652f\u6301&#xff09;&#xff0c;\u540c\u65f6\u652f\u6301\u8d1f\u8f7d\u5747\u8861\u3001\u7f13\u5b58\u3001\u4f1a\u8bdd\u4fdd\u6301\u3002<\/p>\n<h4>5.1 \u6838\u5fc3\u6982\u5ff5<\/h4>\n<li>\u540c\u6784\u4ee3\u7406&#xff1a;\u5ba2\u6237\u7aef\u8bf7\u6c42\u901a\u8fc7 HTTP\/TCP \u534f\u8bae\u76f4\u63a5\u8f6c\u53d1\u81f3\u540e\u7aef\u540c\u7c7b\u670d\u52a1\u5668&#xff08;\u5982 Nginx\u2192Apache&#xff09;&#xff1b;<\/li>\n<li>\u5f02\u6784\u4ee3\u7406&#xff1a;\u5ba2\u6237\u7aef\u8bf7\u6c42\u901a\u8fc7\u4e13\u7528\u534f\u8bae\u8f6c\u53d1\u81f3\u540e\u7aef\u5e94\u7528\u670d\u52a1\u5668&#xff08;\u5982 Nginx\u2192PHP-FPM&#xff0c;FastCGI \u534f\u8bae&#xff09;&#xff1b;<\/li>\n<li>\u8d1f\u8f7d\u5747\u8861&#xff1a;\u5c06\u5ba2\u6237\u7aef\u8bf7\u6c42\u5747\u5300\u5206\u53d1\u81f3\u591a\u4e2a\u540e\u7aef\u670d\u52a1\u5668&#xff0c;\u63d0\u5347\u5e76\u53d1\u80fd\u529b\u3001\u5b9e\u73b0\u6545\u969c\u8f6c\u79fb&#xff1b;<\/li>\n<li>\u52a8\u9759\u5206\u79bb&#xff1a;\u9759\u6001\u8d44\u6e90&#xff08;HTML\u3001\u56fe\u7247\u3001JS&#xff09;\u7531 Nginx \u76f4\u63a5\u8fd4\u56de&#xff0c;\u52a8\u6001\u8d44\u6e90&#xff08;PHP\u3001Java&#xff09;\u8f6c\u53d1\u81f3\u540e\u7aef\u5e94\u7528\u670d\u52a1\u5668&#xff0c;\u63d0\u5347\u6574\u4f53\u6027\u80fd\u3002<\/li>\n<h4>5.2 \u4e03\u5c42\u53cd\u5411\u4ee3\u7406&#xff08;HTTP\/HTTPS&#xff09;<\/h4>\n<p>\u57fa\u4e8engx_http_proxy_module\u5b9e\u73b0&#xff0c;\u6838\u5fc3\u6307\u4ee4\u4e3aproxy_pass&#xff0c;\u652f\u6301\u914d\u7f6e\u4ee3\u7406\u53c2\u6570\u3001\u7f13\u5b58\u3001\u4f1a\u8bdd\u4fdd\u6301\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"429\" src=\"2026-02-24giy5unhtzn1.png\" width=\"913\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"953\" src=\"2026-02-24qulidlgzg1y.png\" width=\"1028\" \/><\/p>\n<p>\u540c\u6784\u4ee3\u7406&#xff1a;\u7528\u6237\u4e0d\u9700\u8981\u5176\u4ed6\u7a0b\u5e8f\u7684\u53c2\u4e0e&#xff0c;\u76f4\u63a5\u901a\u8fc7http\u534f\u8bae\u6216\u8005tcp\u534f\u8bae\u8bbf\u95ee\u540e\u7aef\u670d\u52a1\u5668<\/p>\n<p>\u5f02\u6784\u4ee3\u7406&#xff1a;\u7528\u6237\u8bbf\u95ee\u7684\u8d44\u6e90\u65f6\u9700\u8981\u7ecf\u8fc7\u5904\u7406\u540e\u624d\u80fd\u8fd4\u56de\u7684&#xff0c;\u6bd4\u5982php&#xff0c;Python&#xff0c;\u7b49\u7b49&#xff0c;\u8fd9\u79cd\u8bbf\u95ee\u8d44\u6e90\u9700 \u8981\u7ecf\u8fc7\u5904\u7406\u624d\u80fd\u88ab\u8bbf\u95ee<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"500\" src=\"2026-02-24wiojkxmhvb0.png\" width=\"1049\" \/><\/p>\n<h5>5.2.1 \u6838\u5fc3\u4ee3\u7406\u6307\u4ee4<\/h5>\n<table>\n<tr>\u6307\u4ee4\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>proxy_pass \u5730\u5740&#xff1b;<\/td>\n<td>\u6838\u5fc3\u6307\u4ee4&#xff0c;\u8f6c\u53d1\u8bf7\u6c42\u81f3\u540e\u7aef\u670d\u52a1\u5668&#xff08;IP: \u7aef\u53e3 \/ \u57df\u540d \/upstream \u7ec4&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>proxy_set_header \u5934\u540d \u503c&#xff1b;<\/td>\n<td>\u4fee\u6539 \/ \u6dfb\u52a0\u8bf7\u6c42\u5934&#xff0c;\u8f6c\u53d1\u81f3\u540e\u7aef\u670d\u52a1\u5668<\/td>\n<\/tr>\n<tr>\n<td>proxy_connect_timeout n;<\/td>\n<td>Nginx \u4e0e\u540e\u7aef\u670d\u52a1\u5668\u7684\u8fde\u63a5\u8d85\u65f6\u65f6\u95f4<\/td>\n<\/tr>\n<tr>\n<td>proxy_read_timeout n;<\/td>\n<td>Nginx \u7b49\u5f85\u540e\u7aef\u670d\u52a1\u5668\u54cd\u5e94\u7684\u8d85\u65f6\u65f6\u95f4<\/td>\n<\/tr>\n<tr>\n<td>proxy_hide_header \u5934\u540d&#xff1b;<\/td>\n<td>\u9690\u85cf\u540e\u7aef\u670d\u52a1\u5668\u7684\u54cd\u5e94\u5934&#xff0c;\u4e0d\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef<\/td>\n<\/tr>\n<tr>\n<td>proxy_pass_header \u5934\u540d&#xff1b;<\/td>\n<td>\u900f\u4f20\u540e\u7aef\u670d\u52a1\u5668\u7684\u54cd\u5e94\u5934&#xff0c;\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>5.2.2 \u5173\u952e\u914d\u7f6e&#xff1a;proxy_pass \u672b\u5c3e \/ \u7684\u5f71\u54cd<\/h5>\n<p>proxy_pass\u672b\u5c3e\u662f\u5426\u52a0 **\/**&#xff0c;\u51b3\u5b9a URI \u7684\u8f6c\u53d1\u89c4\u5219&#xff0c;\u6838\u5fc3\u533a\u522b&#xff1a;<\/p>\n<li>\u4e0d\u52a0 \/&#xff1a;\u5c06 location \u7684 URI \u62fc\u63a5\u81f3\u540e\u7aef\u5730\u5740\u540e&#xff1b;\u793a\u4f8b&#xff1a;location \/web { proxy_pass http:\/\/172.25.254.30:8080; } \u2192 \u8bbf\u95ee\/web\/index.html\u8f6c\u53d1\u81f3http:\/\/172.25.254.30:8080\/web\/index.html&#xff1b;<\/li>\n<li>\u52a0 \/&#xff1a;\u5c06 location \u7684 URI \u66ff\u6362\u4e3a\u540e\u7aef\u5730\u5740\u7684 \/&#xff0c;\u4e0d\u62fc\u63a5&#xff1b;\u793a\u4f8b&#xff1a;location \/web { proxy_pass http:\/\/172.25.254.30:8080\/; } \u2192 \u8bbf\u95ee\/web\/index.html\u8f6c\u53d1\u81f3http:\/\/172.25.254.30:8080\/index.html\u3002<\/li>\n<h5>5.2.3 \u5ba2\u6237\u7aef\u771f\u5b9e IP \u900f\u4f20<\/h5>\n<p>Nginx \u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u65f6&#xff0c;\u540e\u7aef\u670d\u52a1\u5668\u83b7\u53d6\u7684 IP \u4e3a Nginx \u7684 IP&#xff0c;\u9700\u901a\u8fc7proxy_set_header\u900f\u4f20\u5ba2\u6237\u7aef\u771f\u5b9e IP&#xff1a;<\/p>\n<p>location \/ {<br \/>\n    proxy_pass http:\/\/172.25.254.30;<br \/>\n    # \u900f\u4f20\u5ba2\u6237\u7aef\u771f\u5b9eIP<br \/>\n    proxy_set_header X-Forwarded-For $remote_addr;<br \/>\n    # \u900f\u4f20\u8bf7\u6c42\u4e3b\u673a\u540d<br \/>\n    proxy_set_header Host $host;<br \/>\n    # \u900f\u4f20\u8bf7\u6c42\u534f\u8bae<br \/>\n    proxy_set_header X-Forwarded-Proto $scheme;<br \/>\n}<\/p>\n<p>\u540e\u7aef\u670d\u52a1\u5668\u9700\u914d\u7f6e\u65e5\u5fd7\u683c\u5f0f&#xff0c;\u8bb0\u5f55X-Forwarded-For\u5b57\u6bb5\u3002<\/p>\n<h5>5.2.4 \u53cd\u5411\u4ee3\u7406\u7f13\u5b58<\/h5>\n<p>\u542f\u7528\u4ee3\u7406\u7f13\u5b58&#xff0c;\u5c06\u540e\u7aef\u670d\u52a1\u5668\u7684\u54cd\u5e94\u7ed3\u679c\u7f13\u5b58\u81f3 Nginx \u672c\u5730&#xff0c;\u51cf\u5c11\u540e\u7aef\u8bf7\u6c42&#xff0c;\u63d0\u5347\u54cd\u5e94\u901f\u5ea6&#xff0c;\u6838\u5fc3\u6307\u4ee4\u4e3aproxy_cache\u3002<\/p>\n<h6>5.2.4.1 \u6838\u5fc3\u7f13\u5b58\u6307\u4ee4<\/h6>\n<p>http {<br \/>\n    # \u5b9a\u4e49\u7f13\u5b58\u6c60&#xff0c;\u914d\u7f6e\u5728http\u6bb5<br \/>\n    proxy_cache_path \/var\/cache\/nginx\/proxy_cache \\\\<br \/>\n    levels&#061;1:2:2 \\\\ # \u7f13\u5b58\u76ee\u5f55\u5c42\u6b21<br \/>\n    keys_zone&#061;proxycache:20m \\\\ # \u5185\u5b58\u7f13\u5b58\u533a&#xff08;20M&#xff0c;\u5b58\u653ekey\u548c\u5143\u6570\u636e&#xff09;<br \/>\n    inactive&#061;120s \\\\ # \u7f13\u5b58\u975e\u6d3b\u52a8\u65f6\u95f4&#xff0c;\u8d85\u65f6\u6e05\u7406<br \/>\n    max_size&#061;10g; # \u7f13\u5b58\u6700\u5927\u78c1\u76d8\u5360\u7528<br \/>\n    server {<br \/>\n        listen 80;<br \/>\n        server_name www.timinglee.org;<br \/>\n        location \/ {<br \/>\n            proxy_pass http:\/\/172.25.254.30;<br \/>\n            proxy_cache proxycache; # \u542f\u7528\u7f13\u5b58\u6c60<br \/>\n            proxy_cache_key $request_uri; # \u7f13\u5b58key&#xff08;\u57fa\u4e8eURI&#xff09;<br \/>\n            proxy_cache_valid 200 302 10m; # 200\/302\u72b6\u6001\u7801\u7f13\u5b5810\u5206\u949f<br \/>\n            proxy_cache_valid 404 1m; # 404\u72b6\u6001\u7801\u7f13\u5b581\u5206\u949f<br \/>\n            proxy_cache_valid any 1m; # \u5176\u4ed6\u72b6\u6001\u7801\u7f13\u5b581\u5206\u949f<br \/>\n            proxy_cache_use_stale error http_502 http_503; # \u540e\u7aef\u9519\u8bef\u65f6\u4f7f\u7528\u8fc7\u671f\u7f13\u5b58<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<h4>5.3 \u4e03\u5c42\u8d1f\u8f7d\u5747\u8861&#xff08;http_upstream&#xff09;<\/h4>\n<p>\u57fa\u4e8engx_http_upstream_module\u5b9e\u73b0&#xff0c;\u901a\u8fc7upstream\u6307\u4ee4\u5b9a\u4e49\u540e\u7aef\u670d\u52a1\u5668\u7ec4&#xff0c;\u5b9e\u73b0\u8bf7\u6c42\u5206\u53d1&#xff0c;\u652f\u6301\u591a\u79cd\u8c03\u5ea6\u7b97\u6cd5\u548c\u540e\u7aef\u670d\u52a1\u5668\u72b6\u6001\u7ba1\u7406&#xff0c;\u662f\u9ad8\u53ef\u7528\u67b6\u6784\u7684\u6838\u5fc3\u3002<\/p>\n<h5>5.3.1 upstream \u6838\u5fc3\u914d\u7f6e<\/h5>\n<p>http {<br \/>\n    # \u5b9a\u4e49\u540e\u7aef\u670d\u52a1\u5668\u7ec4&#xff0c;\u540d\u79f0\u4e3awebserver<br \/>\n    upstream webserver {<br \/>\n        server 172.25.254.20:80 weight&#061;2; # \u6743\u91cd2&#xff0c;\u4f18\u5148\u7ea7\u66f4\u9ad8<br \/>\n        server 172.25.254.30:80 weight&#061;1; # \u6743\u91cd1<br \/>\n        server 172.25.254.40:80 backup; # \u5907\u4efd\u670d\u52a1\u5668&#xff0c;\u4e3b\u670d\u52a1\u5668\u4e0d\u53ef\u7528\u65f6\u542f\u7528<br \/>\n        server 172.25.254.50:80 down; # \u6807\u8bb0\u4e3a\u4e0b\u7ebf&#xff0c;\u5e73\u6ed1\u79fb\u9664<br \/>\n    }<br \/>\n    server {<br \/>\n        listen 80;<br \/>\n        server_name www.timinglee.org;<br \/>\n        # \u8f6c\u53d1\u81f3upstream\u7ec4<br \/>\n        location \/ {<br \/>\n            proxy_pass http:\/\/webserver;<br \/>\n            proxy_set_header X-Forwarded-For $remote_addr;<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<h5>5.3.2 \u540e\u7aef\u670d\u52a1\u5668\u53c2\u6570<\/h5>\n<table>\n<tr>\u53c2\u6570\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>weight&#061;n<\/td>\n<td>\u8c03\u5ea6\u6743\u91cd&#xff0c;\u9ed8\u8ba4\u4e3a 1&#xff0c;\u503c\u8d8a\u9ad8\u88ab\u8c03\u5ea6\u7684\u6982\u7387\u8d8a\u5927<\/td>\n<\/tr>\n<tr>\n<td>max_fails&#061;n<\/td>\n<td>\u8fde\u7eed\u5931\u8d25 n \u6b21\u540e&#xff0c;\u6807\u8bb0\u670d\u52a1\u5668\u4e3a\u4e0d\u53ef\u7528<\/td>\n<\/tr>\n<tr>\n<td>fail_timeout&#061;n<\/td>\n<td>\u670d\u52a1\u5668\u4e0d\u53ef\u7528\u540e&#xff0c;\u6bcf\u9694 n \u79d2\u68c0\u6d4b\u4e00\u6b21&#xff0c;\u6062\u590d\u540e\u91cd\u65b0\u52a0\u5165\u8c03\u5ea6<\/td>\n<\/tr>\n<tr>\n<td>backup<\/td>\n<td>\u5907\u4efd\u670d\u52a1\u5668&#xff0c;\u6240\u6709\u4e3b\u670d\u52a1\u5668\u4e0d\u53ef\u7528\u65f6\u542f\u7528<\/td>\n<\/tr>\n<tr>\n<td>down<\/td>\n<td>\u6807\u8bb0\u670d\u52a1\u5668\u4e3a\u4e0b\u7ebf&#xff0c;\u4e0d\u53c2\u4e0e\u8c03\u5ea6<\/td>\n<\/tr>\n<tr>\n<td>max_conns&#061;n<\/td>\n<td>\u670d\u52a1\u5668\u6700\u5927\u5e76\u53d1\u8fde\u63a5\u6570&#xff0c;\u9ed8\u8ba4\u4e3a 0&#xff08;\u65e0\u9650\u5236&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>5.3.3 \u8c03\u5ea6\u7b97\u6cd5<\/h5>\n<p>Nginx \u5185\u7f6e\u591a\u79cd\u8c03\u5ea6\u7b97\u6cd5&#xff0c;\u9002\u7528\u4e8e\u4e0d\u540c\u573a\u666f&#xff1a;<\/p>\n<table>\n<tr>\u7b97\u6cd5\u539f\u7406\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>\u8f6e\u8be2&#xff08;\u9ed8\u8ba4&#xff09;<\/td>\n<td>\u6309\u987a\u5e8f\u4f9d\u6b21\u5206\u53d1\u8bf7\u6c42\u81f3\u540e\u7aef\u670d\u52a1\u5668<\/td>\n<td>\u540e\u7aef\u670d\u52a1\u5668\u914d\u7f6e\u4e00\u81f4<\/td>\n<\/tr>\n<tr>\n<td>\u52a0\u6743\u8f6e\u8be2<\/td>\n<td>\u6309\u6743\u91cd\u5206\u53d1&#xff0c;\u6743\u91cd\u8d8a\u9ad8\u5206\u53d1\u8d8a\u591a<\/td>\n<td>\u540e\u7aef\u670d\u52a1\u5668\u914d\u7f6e\u4e0d\u4e00\u81f4&#xff08;\u6027\u80fd\u5dee\u5f02&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>ip_hash<\/td>\n<td>\u57fa\u4e8e\u5ba2\u6237\u7aef IP \u54c8\u5e0c&#xff0c;\u56fa\u5b9a IP \u8f6c\u53d1\u81f3\u56fa\u5b9a\u670d\u52a1\u5668<\/td>\n<td>\u9700\u4f1a\u8bdd\u4fdd\u6301\u7684\u573a\u666f&#xff08;\u5982\u767b\u5f55\u72b6\u6001&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>least_conn<\/td>\n<td>\u5206\u53d1\u81f3\u5f53\u524d\u5e76\u53d1\u8fde\u63a5\u6570\u6700\u5c11\u7684\u670d\u52a1\u5668<\/td>\n<td>\u540e\u7aef\u670d\u52a1\u5668\u8bf7\u6c42\u5904\u7406\u65f6\u95f4\u5dee\u5f02\u5927<\/td>\n<\/tr>\n<tr>\n<td>hash $key<\/td>\n<td>\u57fa\u4e8e\u81ea\u5b9a\u4e49 key \u54c8\u5e0c&#xff08;\u5982\u3001cookie&#xff09;<\/td>\n<td>\u7f13\u5b58\u670d\u52a1\u5668\u3001\u9700\u6309 URL\/COOKIE \u4f1a\u8bdd\u4fdd\u6301<\/td>\n<\/tr>\n<tr>\n<td>fair<\/td>\n<td>\u57fa\u4e8e\u540e\u7aef\u670d\u52a1\u5668\u54cd\u5e94\u65f6\u95f4\u5206\u53d1&#xff0c;\u54cd\u5e94\u8d8a\u5feb\u4f18\u5148\u7ea7\u8d8a\u9ad8<\/td>\n<td>\u7b2c\u4e09\u65b9\u6a21\u5757&#xff0c;\u9700\u5355\u72ec\u7f16\u8bd1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>5.4 \u56db\u5c42\u53cd\u5411\u4ee3\u7406&#xff08;TCP\/UDP&#xff09;<\/h4>\n<p>\u57fa\u4e8engx_stream_proxy_module\u5b9e\u73b0&#xff08;\u7f16\u8bd1\u65f6\u9700&#8211;with-stream&#xff09;&#xff0c;\u5de5\u4f5c\u5728TCP\/IP \u56db\u5c42\u534f\u8bae\u6808&#xff0c;\u4e0d\u89e3\u6790\u5e94\u7528\u5c42\u534f\u8bae&#xff0c;\u652f\u6301 TCP\/UDP \u534f\u8bae\u7684\u8d1f\u8f7d\u5747\u8861&#xff0c;\u9002\u7528\u4e8e MySQL\u3001Redis\u3001DNS \u7b49\u975e HTTP \u670d\u52a1\u3002<\/p>\n<h5>5.4.1 TCP \u8d1f\u8f7d\u5747\u8861&#xff08;\u4ee5 MySQL \u4e3a\u4f8b&#xff09;<\/h5>\n<p># \u56db\u5c42\u914d\u7f6e\u6bb5&#xff0c;\u4e0ehttp\u540c\u7ea7<br \/>\nstream {<br \/>\n    # \u5b9a\u4e49MySQL\u540e\u7aef\u670d\u52a1\u5668\u7ec4<br \/>\n    upstream mysql_server {<br \/>\n        server 172.25.254.20:3306 max_fails&#061;3 fail_timeout&#061;30s;<br \/>\n        server 172.25.254.30:3306 max_fails&#061;3 fail_timeout&#061;30s;<br \/>\n    }<br \/>\n    # \u76d1\u542cTCP 3306\u7aef\u53e3&#xff0c;\u8f6c\u53d1\u81f3MySQL\u7ec4<br \/>\n    server {<br \/>\n        listen 172.25.254.10:3306 tcp;<br \/>\n        proxy_pass mysql_server;<br \/>\n        proxy_connect_timeout 30s; # \u8fde\u63a5\u8d85\u65f6<br \/>\n        proxy_timeout 300s; # \u8f6c\u53d1\u8d85\u65f6<br \/>\n    }<br \/>\n}<\/p>\n<h5>5.4.2 UDP \u8d1f\u8f7d\u5747\u8861&#xff08;\u4ee5 DNS \u4e3a\u4f8b&#xff09;<\/h5>\n<p>stream {<br \/>\n    # \u5b9a\u4e49DNS\u540e\u7aef\u670d\u52a1\u5668\u7ec4<br \/>\n    upstream dns_server {<br \/>\n        server 172.25.254.20:53;<br \/>\n        server 172.25.254.30:53;<br \/>\n    }<br \/>\n    # \u76d1\u542cUDP 53\u7aef\u53e3&#xff0c;\u8f6c\u53d1\u81f3DNS\u7ec4<br \/>\n    server {<br \/>\n        listen 172.25.254.10:53 udp;<br \/>\n        proxy_pass dns_server;<br \/>\n        proxy_timeout 1s;<br \/>\n        proxy_responses 1; # UDP\u534f\u8bae&#xff0c;\u54cd\u5e941\u4e2a\u62a5\u6587\u540e\u7ec8\u6b62\u4f1a\u8bdd<br \/>\n    }<br \/>\n}<\/p>\n<h3>\u516d\u3001Nginx \u4e0e FastCGI \u96c6\u6210&#xff08;LNMP \u67b6\u6784&#xff09;<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"371\" src=\"2026-02-24wpgyo41rq30.png\" width=\"857\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"209\" src=\"2026-02-24whw3ustopbs.png\" width=\"970\" \/><\/p>\n<p>LNMP&#xff08;Linux&#043;Nginx&#043;MySQL&#043;PHP&#xff09;\u662f\u4e3b\u6d41\u7684\u52a8\u6001\u7f51\u7ad9\u67b6\u6784&#xff0c;Nginx \u4e0d\u652f\u6301\u76f4\u63a5\u8fd0\u884c PHP&#xff0c;\u9700\u901a\u8fc7FastCGI \u534f\u8bae\u5c06 PHP \u8bf7\u6c42\u8f6c\u53d1\u81f3PHP-FPM&#xff08;FastCGI \u8fdb\u7a0b\u7ba1\u7406\u5668&#xff09;\u5904\u7406&#xff0c;\u5b9e\u73b0\u52a8\u6001\u8d44\u6e90\u89e3\u6790\u3002<\/p>\n<h4>6.1 \u6838\u5fc3\u6982\u5ff5<\/h4>\n<li>CGI&#xff1a;\u901a\u7528\u7f51\u5173\u63a5\u53e3&#xff0c;Web \u670d\u52a1\u5668\u4e0e\u5916\u90e8\u5e94\u7528\u7a0b\u5e8f\u7684\u901a\u4fe1\u6807\u51c6&#xff0c;\u6bcf\u8bf7\u6c42\u521b\u5efa\u4e00\u4e2a\u8fdb\u7a0b&#xff0c;\u6548\u7387\u4f4e&#xff1b;<\/li>\n<li>FastCGI&#xff1a;CGI \u7684\u5347\u7ea7\u7248&#xff0c;\u91c7\u7528\u957f\u8fde\u63a5&#xff0c;\u8fdb\u7a0b\u5904\u7406\u5b8c\u8bf7\u6c42\u540e\u4e0d\u9500\u6bc1&#xff0c;\u53ef\u91cd\u590d\u4f7f\u7528&#xff0c;\u5927\u5e45\u63d0\u5347\u6548\u7387&#xff1b;<\/li>\n<li>PHP-FPM&#xff1a;FastCGI \u7684 PHP \u5b9e\u73b0&#xff0c;\u8d1f\u8d23\u7ba1\u7406 PHP \u8fdb\u7a0b&#xff08;Master&#043;Worker&#xff09;&#xff0c;\u76d1\u542c\u7aef\u53e3\u63a5\u6536 Nginx \u7684 FastCGI \u8bf7\u6c42&#xff1b;<\/li>\n<li>LNMP \u5de5\u4f5c\u6d41\u7a0b&#xff1a;\u5ba2\u6237\u7aef\u2192Nginx&#xff08;\u5904\u7406\u9759\u6001\u8d44\u6e90&#xff09;\u2192FastCGI\u2192PHP-FPM&#xff08;\u5904\u7406 PHP \u4ee3\u7801&#xff09;\u2192MySQL&#xff08;\u83b7\u53d6\u6570\u636e&#xff09;\u2192Nginx\u2192\u5ba2\u6237\u7aef\u3002<\/li>\n<h4>6.2 \u6838\u5fc3\u914d\u7f6e\u6307\u4ee4&#xff08;ngx_http_fastcgi_module&#xff09;<\/h4>\n<p>Nginx \u901a\u8fc7fastcgi_pass\u6307\u4ee4\u8f6c\u53d1 PHP \u8bf7\u6c42\u81f3 PHP-FPM&#xff0c;\u6838\u5fc3\u6307\u4ee4\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>\u6307\u4ee4\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>fastcgi_pass \u5730\u5740&#xff1b;<\/td>\n<td>\u8f6c\u53d1 PHP \u8bf7\u6c42\u81f3 PHP-FPM&#xff08;127.0.0.1:9000 \/ \u672c\u5730\u5957\u63a5\u5b57&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>fastcgi_index index.php;<\/td>\n<td>PHP \u9ed8\u8ba4\u9996\u9875\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>fastcgi_param \u952e \u503c&#xff1b;<\/td>\n<td>\u8bbe\u7f6e FastCGI \u53c2\u6570&#xff0c;\u4f20\u9012\u7ed9 PHP-FPM<\/td>\n<\/tr>\n<tr>\n<td>include fastcgi_params;<\/td>\n<td>\u5f15\u5165 FastCGI \u9ed8\u8ba4\u53c2\u6570\u6587\u4ef6&#xff08;\u5fc5\u52a0&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>6.3 LNMP \u67b6\u6784\u5b9e\u6218\u914d\u7f6e<\/h4>\n<h5>6.3.1 PHP-FPM \u914d\u7f6e<\/h5>\n<p>PHP-FPM \u9ed8\u8ba4\u76d1\u542c127.0.0.1:9000&#xff0c;\u9700\u786e\u4fdd\u914d\u7f6e\u6b63\u786e&#xff0c;\u542f\u52a8 PHP-FPM \u670d\u52a1\u3002<\/p>\n<h5>6.3.2 Nginx \u914d\u7f6e<\/h5>\n<p>server {<br \/>\n    listen 80;<br \/>\n    server_name php.timinglee.org;<br \/>\n    root \/webdata\/nginx\/php\/html; # PHP\u7ad9\u70b9\u6839\u76ee\u5f55<br \/>\n    index index.html index.php; # \u652f\u6301PHP\u9996\u9875<br \/>\n    # \u5339\u914d\u6240\u6709.php\u6587\u4ef6&#xff0c;\u8f6c\u53d1\u81f3PHP-FPM<br \/>\n    location ~ \\\\.php$ {<br \/>\n        fastcgi_pass 127.0.0.1:9000; # PHP-FPM\u76d1\u542c\u5730\u5740<br \/>\n        fastcgi_index index.php;<br \/>\n        # \u5b9a\u4e49PHP\u811a\u672c\u6587\u4ef6\u8def\u5f84&#xff0c;\u5fc5\u987b\u6b63\u786e<br \/>\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br \/>\n        include fastcgi_params; # \u5f15\u5165\u9ed8\u8ba4\u53c2\u6570<br \/>\n    }<br \/>\n    # \u5904\u7406\u9759\u6001\u8d44\u6e90&#xff0c;Nginx\u76f4\u63a5\u8fd4\u56de<br \/>\n    location ~ \\\\.(jpg|png|gif|css|js)$ {<br \/>\n        expires 30d; # \u6d4f\u89c8\u5668\u7f13\u5b5830\u5929<br \/>\n    }<br \/>\n}<\/p>\n<h5>6.3.3 \u6d4b\u8bd5 PHP \u89e3\u6790<\/h5>\n<p>\u5728 PHP \u7ad9\u70b9\u6839\u76ee\u5f55\u521b\u5efainfo.php&#xff0c;\u8bbf\u95ee\u6d4b\u8bd5 PHP \u662f\u5426\u89e3\u6790\u6210\u529f&#xff1a;<\/p>\n<p>&lt;?php<br \/>\nphpinfo();<br \/>\n?&gt;<\/p>\n<p>\u8bbf\u95eehttp:\/\/php.timinglee.org\/info.php&#xff0c;\u663e\u793a PHP \u4fe1\u606f\u9875\u9762\u5373\u4e3a\u914d\u7f6e\u6210\u529f\u3002<\/p>\n<h4>6.4 PHP \u6027\u80fd\u4f18\u5316&#xff1a;\u7f13\u5b58\u6a21\u5757<\/h4>\n<p>\u4e3a PHP \u6dfb\u52a0\u5185\u5b58\u7f13\u5b58&#xff08;\u5982 Memcache\u3001Redis&#xff09;&#xff0c;\u51cf\u5c11\u6570\u636e\u5e93\u8bf7\u6c42&#xff0c;\u63d0\u5347 PHP \u5904\u7406\u6548\u7387&#xff0c;\u4ee5 Memcache \u4e3a\u4f8b&#xff1a;<\/p>\n<li>\u5b89\u88c5 PHP Memcache \u6269\u5c55&#xff1b;<\/li>\n<li>\u90e8\u7f72 Memcached \u670d\u52a1&#xff1b;<\/li>\n<li>Nginx \u914d\u7f6e\u7f13\u5b58\u8f6c\u53d1&#xff0c;PHP \u4ee3\u7801\u8c03\u7528 Memcache\u3002<\/li>\n<h3>\u4e03\u3001Nginx \u4e8c\u6b21\u5f00\u53d1\u7248\u672c<\/h3>\n<h4>7.1 OpenResty<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"177\" src=\"2026-02-242rchesh2gi0.png\" width=\"756\" \/><\/p>\n<h5>7.1.1 \u57fa\u7840\u4ecb\u7ecd<\/h5>\n<p>OpenResty \u662f\u7531\u7ae0\u4ea6\u6625\u56e2\u961f\u5f00\u53d1\u7684\u9ad8\u6027\u80fd Web \u5e73\u53f0&#xff0c;\u57fa\u4e8eNginx&#043;LuaJIT\u5b9e\u73b0&#xff0c;\u5c06 Lua \u865a\u62df\u673a\u5d4c\u5165 Nginx&#xff0c;\u652f\u6301\u901a\u8fc7 Lua \u811a\u672c\u6269\u5c55 Nginx \u529f\u80fd&#xff0c;\u65e0\u9700\u4fee\u6539 Nginx \u6e90\u7801\u3002<\/p>\n<p>\u6838\u5fc3\u4f18\u52bf&#xff1a;<\/p>\n<ul>\n<li>\u8d85\u9ad8\u5e76\u53d1&#xff1a;\u652f\u6301 10K~1000K \u5355\u673a\u5e76\u53d1\u8fde\u63a5&#xff1b;<\/li>\n<li>\u7075\u6d3b\u6269\u5c55&#xff1a;\u901a\u8fc7 Lua \u811a\u672c\u5feb\u901f\u5b9e\u73b0\u81ea\u5b9a\u4e49\u529f\u80fd&#xff08;\u5982\u9650\u6d41\u3001\u9274\u6743\u3001\u7f13\u5b58&#xff09;&#xff1b;<\/li>\n<li>\u4e30\u5bcc\u751f\u6001&#xff1a;\u5185\u7f6e\u5927\u91cf Lua \u5e93\u548c\u7b2c\u4e09\u65b9\u6a21\u5757&#xff0c;\u65e0\u9700\u5355\u72ec\u7f16\u8bd1&#xff1b;<\/li>\n<li>\u4f4e\u5ef6\u8fdf&#xff1a;LuaJIT \u5373\u65f6\u7f16\u8bd1&#xff0c;\u6027\u80fd\u63a5\u8fd1 C \u8bed\u8a00\u3002<\/li>\n<\/ul>\n<p>\u5b98\u7f51&#xff1a;http:\/\/openresty.org\/cn\/<\/p>\n<h5>7.1.2 \u7f16\u8bd1\u5b89\u88c5 OpenResty<\/h5>\n<p># \u5b89\u88c5\u4f9d\u8d56<br \/>\ndnf install gcc pcre-devel openssl-devel perl -y<br \/>\n# \u521b\u5efa\u8fd0\u884c\u7528\u6237<br \/>\nuseradd -r -s \/sbin\/nologin nginx<br \/>\n# \u4e0b\u8f7d\u6e90\u7801\u5e76\u89e3\u538b<br \/>\nwget https:\/\/openresty.org\/download\/openresty-1.17.8.2.tar.gz<br \/>\ntar xf openresty-1.17.8.2.tar.gz &amp;&amp; cd openresty-1.17.8.2<br \/>\n# \u914d\u7f6e\u7f16\u8bd1\u53c2\u6570<br \/>\n.\/configure &#8211;prefix&#061;\/apps\/openresty \\\\<br \/>\n&#8211;user&#061;nginx &#8211;group&#061;nginx \\\\<br \/>\n&#8211;with-http_ssl_module &#8211;with-http_v2_module \\\\<br \/>\n&#8211;with-http_realip_module &#8211;with-http_stub_status_module<br \/>\n# \u7f16\u8bd1\u5e76\u5b89\u88c5<br \/>\nmake &amp;&amp; make install<br \/>\n# \u914d\u7f6e\u73af\u5883\u53d8\u91cf<br \/>\nln -s \/apps\/openresty\/bin\/* \/usr\/bin\/<br \/>\n# \u542f\u52a8\u670d\u52a1<br \/>\nopenresty<\/p>\n<h4>7.2 Tengine<\/h4>\n<p>\u7531\u6dd8\u5b9d\u7f51\u53d1\u8d77\u7684 Nginx \u4e8c\u6b21\u5f00\u53d1\u7248\u672c&#xff0c;\u57fa\u4e8e Nginx \u6dfb\u52a0\u4e86\u5927\u91cf\u9ad8\u7ea7\u529f\u80fd&#xff08;\u5982\u52a8\u6001\u6a21\u5757\u3001\u8bf7\u6c42\u8fc7\u6ee4\u3001\u6027\u80fd\u76d1\u63a7&#xff09;&#xff0c;\u4e13\u95e8\u9488\u5bf9\u5927\u8bbf\u95ee\u91cf\u7f51\u7ad9\u4f18\u5316&#xff0c;\u7a33\u5b9a\u6027\u548c\u6027\u80fd\u7ecf\u8fc7\u6dd8\u5b9d\u3001\u5929\u732b\u7b49\u751f\u4ea7\u73af\u5883\u9a8c\u8bc1&#xff0c;\u5f00\u6e90\u514d\u8d39\u3002<\/p>\n<p>\u5b98\u7f51&#xff1a;http:\/\/tengine.taobao.org\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001Web \u670d\u52a1\u57fa\u7840\u4ecb\u7ecd<br \/>\n1.1 Apache \u7ecf\u5178 Web \u670d\u52a1\u7aef Apache \u5386\u7ecf 1.X\u30012.X \u4e24\u5927\u7248\u672c&#xff0c;\u652f\u6301\u7f16\u8bd1\u5b89\u88c5\u5b9a\u5236\u529f\u80fd&#xff0c;\u6838\u5fc3\u6709\u4e09\u79cd\u5de5\u4f5c\u6a21\u578b&#xff0c;\u5747\u57fa\u4e8e\u591a\u8fdb\u7a0b \/ \u7ebf\u7a0b\u67b6\u6784&#xff0c;\u5404\u6709\u9002\u7528\u573a\u666f&#xff1a;<br \/>\n\u6a21\u578b\u6838\u5fc3\u539f\u7406\u4f18\u70b9\u7f3a\u70b9\u9002\u7528\u573a\u666fprefork&#xff08;\u9884\u6d3e\u751f&#xff09;\u4e3b\u8fdb\u7a0b\u751f\u6210\u591a\u4e2a\u72ec\u7acb\u5b50\u8fdb\u7a0b&#xff0c;\u5355\u8fdb\u7a0b\u5355\u7ebf\u7a0b&#xff0c;select \u6a21\u578b&#xff0c;\u6700\u5927\u5e76\u53d1 1024\u7a33\u5b9a<\/p>\n","protected":false},"author":2,"featured_media":77392,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[763,87,43],"topic":[],"class_list":["post-77412","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-763","tag-87","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4e91\u539f\u751f(\u4f01\u4e1a\u9ad8\u6027\u80fd Web \u670d\u52a1\u5668(Nginx \u6838\u5fc3)) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/77412.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4e91\u539f\u751f(\u4f01\u4e1a\u9ad8\u6027\u80fd Web \u670d\u52a1\u5668(Nginx \u6838\u5fc3)) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001Web \u670d\u52a1\u57fa\u7840\u4ecb\u7ecd 1.1 Apache \u7ecf\u5178 Web \u670d\u52a1\u7aef Apache \u5386\u7ecf 1.X\u30012.X \u4e24\u5927\u7248\u672c&#xff0c;\u652f\u6301\u7f16\u8bd1\u5b89\u88c5\u5b9a\u5236\u529f\u80fd&#xff0c;\u6838\u5fc3\u6709\u4e09\u79cd\u5de5\u4f5c\u6a21\u578b&#xff0c;\u5747\u57fa\u4e8e\u591a\u8fdb\u7a0b \/ \u7ebf\u7a0b\u67b6\u6784&#xff0c;\u5404\u6709\u9002\u7528\u573a\u666f&#xff1a; \u6a21\u578b\u6838\u5fc3\u539f\u7406\u4f18\u70b9\u7f3a\u70b9\u9002\u7528\u573a\u666fprefork&#xff08;\u9884\u6d3e\u751f&#xff09;\u4e3b\u8fdb\u7a0b\u751f\u6210\u591a\u4e2a\u72ec\u7acb\u5b50\u8fdb\u7a0b&#xff0c;\u5355\u8fdb\u7a0b\u5355\u7ebf\u7a0b&#xff0c;select \u6a21\u578b&#xff0c;\u6700\u5927\u5e76\u53d1 1024\u7a33\u5b9a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/77412.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-24T07:59:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075911-699d5a4fd7e88.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/77412.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/77412.html\",\"name\":\"\u4e91\u539f\u751f(\u4f01\u4e1a\u9ad8\u6027\u80fd Web \u670d\u52a1\u5668(Nginx \u6838\u5fc3)) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-24T07:59:18+00:00\",\"dateModified\":\"2026-02-24T07:59:18+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/77412.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/77412.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/77412.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4e91\u539f\u751f(\u4f01\u4e1a\u9ad8\u6027\u80fd Web \u670d\u52a1\u5668(Nginx \u6838\u5fc3))\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4e91\u539f\u751f(\u4f01\u4e1a\u9ad8\u6027\u80fd Web \u670d\u52a1\u5668(Nginx \u6838\u5fc3)) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/77412.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4e91\u539f\u751f(\u4f01\u4e1a\u9ad8\u6027\u80fd Web \u670d\u52a1\u5668(Nginx \u6838\u5fc3)) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001Web \u670d\u52a1\u57fa\u7840\u4ecb\u7ecd 1.1 Apache \u7ecf\u5178 Web \u670d\u52a1\u7aef Apache \u5386\u7ecf 1.X\u30012.X \u4e24\u5927\u7248\u672c&#xff0c;\u652f\u6301\u7f16\u8bd1\u5b89\u88c5\u5b9a\u5236\u529f\u80fd&#xff0c;\u6838\u5fc3\u6709\u4e09\u79cd\u5de5\u4f5c\u6a21\u578b&#xff0c;\u5747\u57fa\u4e8e\u591a\u8fdb\u7a0b \/ \u7ebf\u7a0b\u67b6\u6784&#xff0c;\u5404\u6709\u9002\u7528\u573a\u666f&#xff1a; \u6a21\u578b\u6838\u5fc3\u539f\u7406\u4f18\u70b9\u7f3a\u70b9\u9002\u7528\u573a\u666fprefork&#xff08;\u9884\u6d3e\u751f&#xff09;\u4e3b\u8fdb\u7a0b\u751f\u6210\u591a\u4e2a\u72ec\u7acb\u5b50\u8fdb\u7a0b&#xff0c;\u5355\u8fdb\u7a0b\u5355\u7ebf\u7a0b&#xff0c;select \u6a21\u578b&#xff0c;\u6700\u5927\u5e76\u53d1 1024\u7a33\u5b9a","og_url":"https:\/\/www.wsisp.com\/helps\/77412.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-24T07:59:18+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260224075911-699d5a4fd7e88.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"17 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/77412.html","url":"https:\/\/www.wsisp.com\/helps\/77412.html","name":"\u4e91\u539f\u751f(\u4f01\u4e1a\u9ad8\u6027\u80fd Web \u670d\u52a1\u5668(Nginx \u6838\u5fc3)) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-24T07:59:18+00:00","dateModified":"2026-02-24T07:59:18+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/77412.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/77412.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/77412.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4e91\u539f\u751f(\u4f01\u4e1a\u9ad8\u6027\u80fd Web \u670d\u52a1\u5668(Nginx \u6838\u5fc3))"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/77412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=77412"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/77412\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/77392"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=77412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=77412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=77412"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=77412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}