{"id":61922,"date":"2025-04-29T12:22:14","date_gmt":"2025-04-29T04:22:14","guid":{"rendered":"https:\/\/fwq.ai\/blog\/61922\/"},"modified":"2025-04-29T12:22:14","modified_gmt":"2025-04-29T04:22:14","slug":"nginx%e8%b6%85%e7%ae%80%e5%8d%95%e6%95%99%e7%a8%8b%ef%bc%8c%e5%85%a5%e9%97%a8%e7%9c%8b%e8%bf%99%e7%af%87%e5%b0%b1%e5%a4%9f%e4%ba%86-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/61922\/","title":{"rendered":"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86"},"content":{"rendered":"<h2><span style=\"font-size: inherit;color: inherit;line-height: inherit\">\u4e00 Nginx\u7b80\u4ecb<\/span><\/h2>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">1.1 \u4ec0\u4e48\u662fNginx<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">Nginx\u662f\u4e00\u4e2a\u9ad8\u6027\u80fd\u7684http\u548c\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u5176\u7279\u70b9\u662f\u5360\u7528\u5185\u5b58\u5c0f\uff0c\u5e76\u53d1\u80fd\u529b\u5f3a\u3002Nginx\u4e13\u4e3a\u6027\u80fd\u4f18\u5316\u800c\u5f00\u53d1\uff0c\u6027\u80fd\u662f\u5176\u6700\u91cd\u8981\u7684\u8003\u91cf\uff0c\u80fd\u7ecf\u53d7\u9ad8\u8d1f\u8f7d\u7684\u8003\u9a8c\uff0c\u6709\u62a5\u544a\u8868\u660e\u80fd\u652f\u6301\u9ad8\u8fbe50000\u4e2a\u5e76\u53d1\u8fde\u63a5\u6570\u3002<\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">1.2 \u53cd\u5411\u4ee3\u7406<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u6b63\u5411\u4ee3\u7406\uff1a\u5728\u6d4f\u89c8\u5668\u4e2d\u914d\u7f6e\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u901a\u8fc7\u4ee3\u7406\u670d\u52a1\u5668\u8fdb\u884c\u4e92\u8054\u7f51\u8bbf\u95ee\u3002<\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u53cd\u5411\u4ee3\u7406\uff1a\u5c06\u8bf7\u6c42\u53d1\u9001\u5230\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u7531\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u53bb\u9009\u62e9\u76ee\u6807\u670d\u52a1\u5668\u83b7\u53d6\u6570\u636e\u540e\uff0c\u518d\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\uff0c\u6b64\u65f6\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u5916\u5c31\u662f\u4e00\u4e2a\u670d\u52a1\u5668\uff0c\u66b4\u6f0f\u7684\u662f\u4ee3\u7406\u670d\u52a1\u5668\u5730\u5740\u3002<\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">1.3 \u8d1f\u8f7d\u5747\u8861<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u5982\u679c\u8bf7\u6c42\u6570\u8fc7\u5927\uff0c\u5355\u4e2a\u670d\u52a1\u5668\u89e3\u51b3\u4e0d\u4e86\uff0c\u6211\u4eec\u589e\u52a0\u670d\u52a1\u5668\u7684\u6570\u91cf\uff0c\u7136\u540e\u5c06\u8bf7\u6c42\u5206\u53d1\u5230\u5404\u4e2a\u670d\u52a1\u5668\u4e0a\uff0c\u5c06\u539f\u5148\u8bf7\u6c42\u96c6\u4e2d\u5230\u5355\u4e2a\u670d\u52a1\u5668\u7684\u60c5\u51b5\u6539\u4e3a\u8bf7\u6c42\u5206\u53d1\u5230\u591a\u4e2a\u670d\u52a1\u5668\u4e0a\uff0c\u5c31\u662f\u8d1f\u8f7d\u5747\u8861\u3002<\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">1.4 \u52a8\u9759\u5206\u79bb<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u4e3a\u4e86\u52a0\u5feb\u670d\u52a1\u5668\u7684\u89e3\u6790\u901f\u5ea6\uff0c\u53ef\u4ee5\u628a\u52a8\u6001\u9875\u9762\u548c\u9759\u6001\u9875\u9762\u4ea4\u7ed9\u4e0d\u540c\u7684\u670d\u52a1\u5668\u6765\u89e3\u6790\uff0c\u52a0\u5feb\u89e3\u6790\u901f\u5ea6\uff0c\u964d\u4f4e\u539f\u6765\u5355\u4e2a\u670d\u52a1\u5668\u7684\u538b\u529b\u3002<\/p>\n<h2><span style=\"font-size: inherit;color: inherit;line-height: inherit\">\u4e8c Nginx\u7684\u5b89\u88c5<\/span><\/h2>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">Nginx\u9700\u8981\u51e0\u4e2a\u4f9d\u8d56\u5305\uff0c\u5206\u522b\u662fpcre\uff0copenssl\uff0czlib\uff0c\u5728\u5b89\u88c5\u4e4b\u524d\u9700\u8981\u5148\u5b89\u88c5\u8fd9\u51e0\u4e2a\u4f9d\u8d56\u3002<\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">2.1 \u5b89\u88c5pcre\u4f9d\u8d56<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<ol>\n<li>\n<p>\u4f7f\u7528\u547d\u4ee4\u4e0b\u8f7dpcre\u538b\u7f29\u5305<\/p>\n<\/li>\n<\/ol>\n<pre>1wget&nbsp;http:\/\/downloads.sourceforge.net\/project\/pcre\/pcre\/8.37\/pcre-8.37.tar.gz<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\n<p><span style=\"font-size: inherit;color: inherit;line-height: inherit\">\u89e3\u538b\u538b\u7f29\u6587\u4ef6<\/span><\/p>\n<\/li>\n<\/ol>\n<pre>1tar&nbsp;-xvf&nbsp;&nbsp;pcre-8.37.tar.gz<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\n<p><span style=\"font-size: inherit;color: inherit;line-height: inherit\">\u8fdb\u5165\u89e3\u538b\u540e\u7684\u540d\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4<\/span><\/p>\n<\/li>\n<\/ol>\n<pre>1.\/configure<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\n<p><span style=\"font-size: inherit;color: inherit;line-height: inherit\">\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u7f16\u8bd1\u5b89\u88c5<\/span><\/p>\n<\/li>\n<\/ol>\n<pre>1make&nbsp;&amp;amp;&amp;amp;&nbsp;make&nbsp;install<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\n<p>\u67e5\u770b\u5b89\u88c5\u7684pcre\u7248\u672c\u53f7<\/p>\n<\/li>\n<\/ol>\n<pre>1pcre-config&nbsp;--version<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">2.2 \u5b89\u88c5openssl\uff0czlib\u7b49\u4f9d\u8d56<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<pre>1yum&nbsp;-y&nbsp;install&nbsp;make&nbsp;zlib&nbsp;zlib-devel&nbsp;gcc-c++&nbsp;libtool&nbsp;openssl&nbsp;openssl-devel<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">2.3 \u5b89\u88c5nginx<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<ol>\n<li>\n<p>nginx\u5b98\u7f51\u4e0b\u8f7dnginx\uff0c\u5b98\u7f51\u5730\u5740\uff1ahttps:\/\/nginx.org\/download\/\uff1b<\/p>\n<\/li>\n<li>\n<p><span style=\"font-size: inherit;color: inherit;line-height: inherit\">\u5c06\u538b\u7f29\u5305\u62d6\u5230\u670d\u52a1\u5668\u4e0a;<\/span><\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528\u547d\u4ee4tar -xvf nginx-1.12.2.tar.gz\u89e3\u538b\u538b\u7f29\u5305;<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528\u547d\u4ee4.\/configure\u68c0\u67e5\uff1b<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528\u547d\u4ee4make &amp;&amp; make isntall\u7f16\u8bd1\u5b89\u88c5\uff1b<\/p>\n<\/li>\n<\/ol>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\"><strong>\u5b89\u88c5\u6210\u529f\u540e\uff0c\u5728usr\u4f1a\u591a\u51fa\u6765\u4e00\u4e2a\u6587\u4ef6\u5939\uff0clocal\/nginx\uff0c\u5728nginx\u7684sbin\u6587\u4ef6\u5939\u4e0b\u6709\u542f\u52a8\u811a\u672c\u3002<\/strong><\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">2.4 \u542f\u52a8nginx<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u5728\/usr\/local\/nginx\/sbin\u6587\u4ef6\u5939\u4e0b\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8<\/p>\n<pre>1.\/nginx<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u7136\u540e\u6d4f\u89c8\u5668\u8bbf\u95ee\u670d\u52a1\u5668ip\uff0cnginx\u9ed8\u8ba4\u7aef\u53e3\u662f80\uff0c\u51fa\u73b0\u4ee5\u4e0b\u9875\u9762\u5219\u8bc1\u660enginx\u5b89\u88c5\u6210\u529f\uff1b<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/690\/3c5fc48c58b6ad2b07664ca42215e6c8-0.png\" class=\"aligncenter\" title=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe\" alt=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe\" \/><\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">2.5 Nginx\u5e38\u7528\u7684\u547d\u4ee4<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span><br \/> <\/h3>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u4f7f\u7528\u8fd9\u4e9b\u547d\u4ee4\u65f6\u9700\u8981\u8fdb\u5165\/usr\/local\/nginx\/sbin\u6587\u4ef6\u5939<\/p>\n<ul>\n<li>\n<p>\u67e5\u770bnginx\u7684\u7248\u672c\u53f7<\/p>\n<\/li>\n<\/ul>\n<pre>1.\/nginx&nbsp;-v<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\n<p>\u542f\u52a8nginx<\/p>\n<\/li>\n<\/ul>\n<pre>1.\/nginx<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\n<p>\u5173\u95ednginx<\/p>\n<\/li>\n<\/ul>\n<pre>1.\/nginx&nbsp;-s&nbsp;stop<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\n<p>\u91cd\u65b0\u52a0\u8f7dnginx<\/p>\n<\/li>\n<\/ul>\n<pre>1.\/nginx&nbsp;-s&nbsp;reload<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">2.6 Nginx\u7684\u914d\u7f6e\u6587\u4ef6<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">nginx\u7684\u914d\u7f6e\u6587\u4ef6\u5728\/usr\/local\/nginx\/conf\u4e2d\u7684nginx.conf\u3002\u6211\u4eec\u5c06nginx.conf\u4e2d\u6ce8\u91ca\u7684\u5185\u5bb9\u5220\u9664\u4e00\u4e0b\u3002<\/p>\n<pre>&nbsp;1#user&nbsp;&nbsp;nobody;\n&nbsp;2worker_processes&nbsp;&nbsp;1;\n&nbsp;3\n&nbsp;4#pid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logs\/nginx.pid;\n&nbsp;5\n&nbsp;6events&nbsp;{\n&nbsp;7&nbsp;&nbsp;&nbsp;&nbsp;worker_connections&nbsp;&nbsp;1024;\n&nbsp;8}\n&nbsp;9\n10http&nbsp;{\n11&nbsp;&nbsp;&nbsp;&nbsp;include&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mime.types;\n12&nbsp;&nbsp;&nbsp;&nbsp;default_type&nbsp;&nbsp;application\/octet-stream;\n13\n14&nbsp;&nbsp;&nbsp;&nbsp;sendfile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;on;\n15&nbsp;&nbsp;&nbsp;&nbsp;#tcp_nopush&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;on;\n16\n17&nbsp;&nbsp;&nbsp;&nbsp;#keepalive_timeout&nbsp;&nbsp;0;\n18&nbsp;&nbsp;&nbsp;&nbsp;keepalive_timeout&nbsp;&nbsp;65;\n19\n20&nbsp;&nbsp;&nbsp;&nbsp;#gzip&nbsp;&nbsp;on;\n21\n22&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;{\n23&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;80;\n24&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;localhost;\n25\n26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/&nbsp;{\n27&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;html;\n28&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm;\n29&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n30&nbsp;&nbsp;&nbsp;&nbsp;}\n31}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">nginx\u7684\u914d\u7f6e\u6587\u4ef6\u5305\u542b\u4e09\u90e8\u95e8\u3002<\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\"><strong>1.\u5168\u5c40\u5757<\/strong><\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u4ece\u914d\u7f6e\u6587\u4ef6\u5f00\u59cb\u5230events\u5757\u4e4b\u95f4\u7684\u5185\u5bb9\uff0c\u4e3b\u8981\u4f1a\u8bbe\u7f6e\u4e00\u4e9bnginx\u670d\u52a1\u5668\u6574\u4f53\u8fd0\u884c\u7684\u914d\u7f6e\u6307\u4ee4\u3002<\/p>\n<pre>1worker_processes&nbsp;&nbsp;1;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u8fd9\u4e2a\u4ee3\u8868nginx\u5904\u7406\u5e76\u53d1\u7684\u5173\u952e\u914d\u7f6e\uff0c\u503c\u8d8a\u5927\uff0c\u5904\u7406\u5e76\u53d1\u80fd\u529b\u8d8a\u5f3a\u3002\u4f46\u662f\u4f1a\u53d7\u5230\u786c\u4ef6\u3001\u8f6f\u4ef6\u7b49\u7ea6\u675f\u3002<\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\"><strong>2.events\u5757<\/strong><\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">events\u5757\u6d89\u53ca\u7684\u6307\u4ee4\u4e3b\u8981\u5f71\u54cdnginx\u670d\u52a1\u5668\u4e0e\u7528\u6237\u7f51\u7edc\u7684\u8fde\u63a5\u3002<\/p>\n<pre>1worker_connections&nbsp;&nbsp;1024;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u8fd9\u4e2a\u4ee3\u8868nginx\u652f\u6301\u7684\u6700\u5927\u8fde\u63a5\u6570\u3002<\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\"><strong>3.http\u5168\u5c40\u5757<\/strong><\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">nginx\u670d\u52a1\u5668\u914d\u7f6e\u6700\u9891\u7e41\u7684\u90e8\u5206\u3002http\u5168\u5c40\u5757\u5305\u542bhttp\u5757\u548cserver\u5757\u3002<\/p>\n<h2><span style=\"font-size: inherit;color: inherit;line-height: inherit\">\u4e09 Nginx\u914d\u7f6e\u53cd\u5411\u4ee3\u7406<\/span><\/h2>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">3.1 ngix\u4ee3\u7406\u6d41\u7a0b<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/690\/ccd5ad9fcc194867b6b0877fcc937f74-1.png\" class=\"aligncenter\" title=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe1\" alt=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe1\" \/><\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u672c\u5730\u6d4f\u89c8\u5668\u8bbf\u95eenginx\u670d\u52a1\u5668\uff0cnginx\u670d\u52a1\u5668\u53cd\u5411\u4ee3\u7406tomcat\u670d\u52a1\u5668\uff0c\u5f53\u6211\u4eec\u8bf7\u6c42nginx\u7684\u65f6\u5019\u76f4\u63a5\u8bbf\u95ee\u5230tomcat\u3002tomcat\u7684\u5b89\u88c5\u8fd9\u91cc\u5c31\u4e0d\u5728\u8bb2\u4e86\uff0c\u6211\u5c06tomcat\u548cnginx\u5b89\u88c5\u5728\u4e86\u540c\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\u3002<\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">3.2 \u914d\u7f6eip\u548c\u57df\u540d\u7684\u7ed1\u5b9a\u5173\u7cfb<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u7531\u4e8e\u6211\u4eec\u7684nginx\u6ca1\u6709\u57df\u540d\uff0c\u4e3a\u4e86\u6f14\u793a\uff0c\u56e0\u6b64\u6211\u4eec\u5728\u672c\u5730host\u6587\u4ef6\u4e2d\u914d\u7f6enginx\u670d\u52a1\u5668ip\u548c\u57df\u540d\u8fdb\u884c\u7ed1\u5b9a\u3002\u8fd9\u4e2ahost\u6587\u4ef6\u7684\u5177\u4f53\u4f4d\u7f6e\u5728C:WindowsSystem32driversetc\u3002\u5728host\u6587\u4ef6\u4e2d\u589e\u52a0\u4e00\u53e5\u914d\u7f6e\uff1a<\/p>\n<pre>147.104.xxx.xxx&nbsp;www.javatrip.com<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u524d\u9762\u7684ip\u662f\u670d\u52a1\u5668\u7684ip\u5730\u5740\uff0c\u540e\u9762\u7684\u57df\u540d\u662f\u6211\u968f\u4fbf\u8d77\u7684\u7528\u4e8e\u7ed1\u5b9a\u8fd9\u4e2aip\u7684\u4e00\u4e2a\u57df\u540d\u3002\u914d\u7f6e\u597d\u4e4b\u540e\uff0c\u6211\u4eec\u4f7f\u7528\u57df\u540d\u8bbf\u95ee\u4e00\u4e0btomcat\uff0c\u5982\u679c\u80fd\u8bf7\u6c42\u5230tomcat\u9ed8\u8ba4\u9875\u9762\uff0c\u5219\u914d\u7f6e\u6210\u529f\u3002<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/690\/ccd5ad9fcc194867b6b0877fcc937f74-2.png\" class=\"aligncenter\" title=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe2\" alt=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe2\" \/><\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">3.3 \u5728nginx\u914d\u7f6e\u8bf7\u6c42\u8f6c\u53d1<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span><br \/> <\/h3>\n<pre>1&nbsp;&nbsp;server&nbsp;{\n2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;80;\n3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;localhost;\n4\n5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/&nbsp;{\n6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;html;\n7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm;\n8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n9&nbsp;&nbsp;}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u6211\u4eec\u5c06\u4ee5\u4e0a\u9ed8\u8ba4\u7684\u914d\u7f6e\u6587\u4ef6\u505a\u4e2a\u4fee\u6539\uff1a<\/p>\n<pre>&nbsp;1server&nbsp;{\n&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;80;\n&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;47.104.xxx.xxx;\n&nbsp;4\n&nbsp;5&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/&nbsp;{\n&nbsp;6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;html;\n&nbsp;7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;http:\/\/127.0.0.1:8080;\n&nbsp;8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm;\n&nbsp;9&nbsp;&nbsp;&nbsp;&nbsp;}\n10}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u4ee5\u4e0a\u8fd9\u6bb5\u914d\u7f6e\u7684\u610f\u601d\u5c31\u662f\u8bf7\u6c42\u662f47.104.xxx.xxx:80\uff0c\u90fd\u4f1a\u8f6c\u53d1\u81f347.104.xxx.xxx:8080\u3002<\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u73b0\u5728\u6d4f\u89c8\u5668\u8bbf\u95eewww.javatrip.com\uff0c\u53d1\u73b0\u76f4\u63a5\u8f6c\u53d1\u5230\u4e86tomcat\u4e0a\u4e86\uff0c\u8fd9\u6837\u7b80\u5355\u7684\u53cd\u5411\u4ee3\u7406\u5c31\u5b8c\u6210\u4e86\u3002<\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">3.4 \u6839\u636e\u8bf7\u6c42\u540e\u7f00\u5206\u53d1<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u6211\u4eec\u518d\u89e3\u538b\u4e00\u4e2atomcat\uff0c\u7aef\u53e3\u53f7\u8bbe\u7f6e\u4e3a8081\uff0c\u5206\u522b\u5728\u4e24\u4e2atomcat\u4e0bwebapps\u76ee\u5f55\u4e0b\u9762\u65b0\u5efadev\u548cprod\u76ee\u5f55\uff0c\u7136\u540e\u5728\u8be5\u76ee\u5f55\u4e0b\u5199\u4e00\u4e2a\u6587\u4ef6\u3002<\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u5c06\u8bf7\u6c42www.javatrip.com:7001\/dev\u8f6c\u53d1\u5230tomcat8080\uff0c\u5c06\u8bf7\u6c42www.javatrip.com:7001\/prod\u8f6c\u53d1\u5230tomcat8081\u3002\u73b0\u5728\u6211\u4eec\u7684nginx\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u662f7001\u3002\u6253\u5f00nginx\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u65b0\u5efa\u4e00\u4e2aserver\u5982\u4e0b\uff1a<\/p>\n<pre>&nbsp;1server&nbsp;{\n&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7001;\n&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;47.104.xxx.xxx;\n&nbsp;4\n&nbsp;5&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;~&nbsp;\/dev\/&nbsp;{\n&nbsp;6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;http:\/\/127.0.0.1:8080;\n&nbsp;7&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;8\n&nbsp;9&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;~&nbsp;\/prod\/&nbsp;{\n10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;http:\/\/127.0.0.1:8081;\n11&nbsp;&nbsp;&nbsp;&nbsp;}\n12}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u7136\u540e\u8bd5\u8bd5\u6548\u679c\uff0c\u5206\u522b\u8bbf\u95eewww.javatrip.com:7001\/dev\/a.html\u548cwww.javatrip.com:7001\/prod\/a.html\uff0c\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/690\/ccd5ad9fcc194867b6b0877fcc937f74-3.png\" class=\"aligncenter\" title=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe3\" alt=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe3\" \/><\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/690\/5d5f81269de5e37f74acaab762ce5744-4.png\" class=\"aligncenter\" title=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe4\" alt=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe4\" \/><\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u5176\u4e2d\uff0c\u914d\u7f6e\u8f6c\u53d1\u7684\u65f6\u5019\u7528\u5230\u4e86~\uff0c\u5176\u542b\u4e49\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\n<p><span style=\"font-size: inherit;color: inherit;line-height: inherit\">= \u4e25\u683c\u5339\u914d\u3002\u5982\u679c\u8fd9\u4e2a\u67e5\u8be2\u5339\u914d\uff0c\u90a3\u4e48\u5c06\u505c\u6b62\u641c\u7d22\u5e76\u7acb\u5373\u5904\u7406\u6b64\u8bf7\u6c42\u3002<\/span><\/p>\n<\/li>\n<li>\n<p><span style=\"font-size: inherit;color: inherit;line-height: inherit\">~ \u4e3a\u533a\u5206\u5927\u5c0f\u5199\u5339\u914d(\u53ef\u7528\u6b63\u5219\u8868\u8fbe\u5f0f)<\/span><\/p>\n<\/li>\n<li>\n<p><span style=\"font-size: inherit;color: inherit;line-height: inherit\">!~\u4e3a\u533a\u5206\u5927\u5c0f\u5199\u4e0d\u5339\u914d<\/span><\/p>\n<\/li>\n<li>\n<p><span style=\"font-size: inherit;color: inherit;line-height: inherit\">~* \u4e3a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u5339\u914d(\u53ef\u7528\u6b63\u5219\u8868\u8fbe\u5f0f)<\/span><\/p>\n<\/li>\n<li>\n<p><span style=\"font-size: inherit;color: inherit;line-height: inherit\">!~*\u4e3a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u4e0d\u5339\u914d<\/span><\/p>\n<\/li>\n<li>\n<p>^~ \u5982\u679c\u628a\u8fd9\u4e2a\u524d\u7f00\u7528\u4e8e\u4e00\u4e2a\u5e38\u89c4\u5b57\u7b26\u4e32,\u90a3\u4e48\u544a\u8bc9nginx\u5982\u679c\u8def\u5f84\u5339\u914d\u90a3\u4e48\u4e0d\u6d4b\u8bd5\u6b63\u5219\u8868\u8fbe\u5f0f\u3002<\/p>\n<\/li>\n<\/ul>\n<h2><span style=\"font-size: inherit;color: inherit;line-height: inherit\">\u56db Nginx\u914d\u7f6e\u8d1f\u8f7d\u5747\u8861<\/span><\/h2>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">4.1 \u4ec0\u4e48\u662f\u8d1f\u8f7d\u5747\u8861<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\"><strong>\u8d1f\u8f7d\u5747\u8861\uff08Load Balance\uff09\uff0c\u610f\u601d\u662f\u5c06\u8d1f\u8f7d\uff08\u5de5\u4f5c\u4efb\u52a1\uff0c\u8bbf\u95ee\u8bf7\u6c42\uff09\u8fdb\u884c\u5e73\u8861\u3001\u5206\u644a\u5230\u591a\u4e2a\u64cd\u4f5c\u5355\u5143\uff08\u670d\u52a1\u5668\uff0c\u7ec4\u4ef6\uff09\u4e0a\u8fdb\u884c\u6267\u884c\u3002\u662f\u89e3\u51b3\u9ad8\u6027\u80fd\uff0c\u5355\u70b9\u6545\u969c\uff08\u9ad8\u53ef\u7528\uff09\uff0c\u6269\u5c55\u6027\uff08\u6c34\u5e73\u4f38\u7f29\uff09\u7684\u7ec8\u6781\u89e3\u51b3\u65b9\u6848\u3002<\/strong><\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u73b0\u5728\u6211\u4eec\u60f3\u5b9e\u73b0\u7684\u6548\u679c\u662f\u901a\u8fc7\u8bbf\u95eewww.javatrip.com:7001\/prod\/a.html\uff0c\u5c06\u8bf7\u6c42\u5206\u522b\u5206\u53d1\u5230\u4e24\u4e2atomcat\u4e0a\u9762\u53bb\uff0c\u9996\u5148\u6211\u4eec\u5728tomcat8080\u4e0a\u65b0\u5efa\u4e00\u4e2aprod\u7684\u6587\u4ef6\u5939\uff0c\u91cc\u9762\u653e\u4e00\u4e2aa.html\u7684\u6587\u4ef6\u3002\u8fd9\u6837tomcat8081\u548ctomcat8080\u4e24\u4e2a\u4e0a\u5c31\u90fd\u6709\u4e86\u4e00\u4e2aprod\u7684\u6587\u4ef6\u52a0\u4e14\u91cc\u9762\u6709\u4e00\u4e2aa.html\u7684\u6587\u4ef6\u3002<\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">4.2 \u914d\u7f6enginx.conf<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u9996\u5148\uff0c\u5728http\u5757\u4e2d\u914d\u7f6e\u4e24\u4e2atomcat\u7684\u670d\u52a1\u5217\u8868<\/p>\n<pre>1upstream&nbsp;myserver{\n2&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;127.0.0.1:8080;\n3&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;127.0.0.1:8081;\n4}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u5176\u6b21\uff0c\u5728server\u5757\u4e2d\u914d\u7f6e\u89c4\u5219\uff1a<\/p>\n<pre>&nbsp;1server&nbsp;{\n&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;80;\n&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;47.104.xxx.xxx;\n&nbsp;4\n&nbsp;5&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/&nbsp;{\n&nbsp;6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;html;\n&nbsp;7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;http:\/\/myserver;\n&nbsp;8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm;\n&nbsp;9&nbsp;&nbsp;&nbsp;&nbsp;}\n10}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">4.3 \u6d4b\u8bd5\u6548\u679c<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span> <\/h3>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u8bbf\u95ee\u5730\u5740\uff1awww.javatrip.com:7001\/prod\/a.html\uff0c\u591a\u5237\u65b0\u51e0\u6b21\u3002\u53d1\u73b0\u6709\u7684\u8bf7\u6c42\u5230tomcat8080\u4e0a\uff0c\u6709\u7684\u8bf7\u6c42\u5230tomcat8081\u4e0a\u3002<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/690\/5d5f81269de5e37f74acaab762ce5744-5.png\" class=\"aligncenter\" title=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe5\" alt=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe5\" \/><\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/690\/5d5f81269de5e37f74acaab762ce5744-6.png\" class=\"aligncenter\" title=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe6\" alt=\"Nginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u63d2\u56fe6\" \/><\/p>\n<h3> <span style=\"font-size: inherit;line-height: inherit;font-weight: normal;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">4.4 nginx\u652f\u6301\u7684\u51e0\u79cd\u8d1f\u8f7d\u7b56\u7565<\/span><span style=\"vertical-align: bottom;border-right: 20px solid transparent\"> <\/span><br \/> <\/h3>\n<ul>\n<li>\n<p><span style=\"font-size: inherit;color: inherit;line-height: inherit\">\u8f6e\u8be2\uff08\u9ed8\u8ba4\uff09\uff1a\u6bcf\u4e2a\u8bf7\u6c42\u6309\u65f6\u95f4\u987a\u5e8f\u9010\u4e00\u5206\u914d\u5230\u4e0d\u540c\u7684\u670d\u52a1\u5668\uff0c\u5982\u679c\u670d\u52a1\u5668down\u4e86\uff0c\u4f1a\u81ea\u52a8\u5254\u9664\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<pre>1upstream&nbsp;myserver{\n2&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;127.0.0.1:8080;\n3&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;127.0.0.1:8081;\n4}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\n<p><span style=\"font-size: inherit;color: inherit;line-height: inherit\">weight\uff08\u6743\u91cd\uff09\uff1a\u9ed8\u8ba4\u4e3a1\uff0c\u6743\u91cd\u8d8a\u9ad8\uff0c\u5206\u914d\u7684\u8bf7\u6c42\u8d8a\u591a\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<pre>1upstream&nbsp;myserver{\n2&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;127.0.0.1:8080&nbsp;weight=1;\n3&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;127.0.0.1:8081&nbsp;weight=2;\n4}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\n<p>ip hash\uff1a\u6bcf\u4e2a\u8bf7\u6c42\u6309\u8bbf\u95eeip\u7684hash\u7ed3\u679c\u5206\u914d\uff0c\u8fd9\u6837\u6bcf\u4e2a\u8bbf\u5ba2\u56fa\u5b9a\u8bbf\u95ee\u4e00\u4e2a\u540e\u53f0\u670d\u52a1\u5668\uff0c\u53ef\u4ee5\u89e3\u51b3session\u7684\u95ee\u9898\u3002<\/p>\n<\/li>\n<\/ul>\n<pre>1upstream&nbsp;myserver{\n2&nbsp;&nbsp;&nbsp;&nbsp;ip_hash;\n3&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;127.0.0.1:8080;\n4&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;127.0.0.1:8081;\n5}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\n<p><span style=\"font-size: inherit;color: inherit;line-height: inherit\">fair\uff08\u7b2c\u4e09\u65b9\uff09\uff1a\u6309\u540e\u7aef\u54cd\u5e94\u65f6\u95f4\u8fdb\u884c\u5206\u914d\uff0c\u54cd\u5e94\u65f6\u95f4\u8d8a\u77ed\u5206\u914d\u7684\u8bf7\u6c42\u8d8a\u591a\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<pre>1upstream&nbsp;myserver{\n2&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;127.0.0.1:8080;\n3&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;127.0.0.1:8081;\n4&nbsp;&nbsp;&nbsp;&nbsp;fair;\n5}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-size: inherit;color: inherit;line-height: inherit;margin-top: 1.7em;margin-bottom: 1.7em\">\u7531\u4e8e\u52a8\u9759\u5206\u79bb\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\u4e5f\u4e0d\u5e38\u7528\uff0c\u5c31\u4e0d\u518d\u5199\u4e86\u3002\u672c\u7bc7\u6587\u7ae0\u505a\u4e3a\u4e00\u4e2anginx\u5165\u95e8\uff0c\u5230\u8fd9\u91cc\u5c31\u57fa\u672c\u5b8c\u7ed3\u4e86\u3002\u6700\u540e\u7559\u7ed9\u5927\u5bb6\u4e00\u4e2a\u95ee\u9898\u601d\u8003\u4e00\u4e0b\uff1a<strong>\u5982\u4f55\u4fdd\u8bc1nginx\u7684\u9ad8\u53ef\u7528\uff1f<\/strong><\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fNginx\u8d85\u7b80\u5355\u6559\u7a0b\uff0c\u5165\u95e8\u770b\u8fd9\u7bc7\u5c31\u591f\u4e86\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00 Nginx\u7b80\u4ecb 1.1 \u4ec0\u4e48\u662fNginx Nginx\u662f\u4e00\u4e2a\u9ad8\u6027\u80fd\u7684http\u548c\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u5176\u7279\u70b9\u662f\u5360\u7528\u5185\u5b58\u5c0f\uff0c\u5e76\u53d1\u80fd\u529b\u5f3a\u3002Nginx\u4e13\u4e3a\u6027\u80fd\u4f18\u5316\u800c\u5f00\u53d1\uff0c\u6027\u80fd\u662f\u5176\u6700\u91cd\u8981\u7684\u8003\u91cf\uff0c\u80fd\u7ecf\u53d7\u9ad8\u8d1f\u8f7d\u7684\u8003\u9a8c\uff0c\u6709\u62a5\u544a\u8868\u660e\u80fd\u652f\u6301\u9ad8\u8fbe50000\u4e2a\u5e76\u53d1\u8fde\u63a5\u6570\u3002 1.2 \u53cd\u5411\u4ee3\u7406 \u6b63\u5411\u4ee3\u7406\uff1a\u5728\u6d4f\u89c8\u5668\u4e2d\u914d\u7f6e\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u901a\u8fc7\u4ee3\u7406\u670d\u52a1\u5668\u8fdb\u884c\u4e92\u8054\u7f51\u8bbf\u95ee\u3002 \u53cd\u5411\u4ee3\u7406\uff1a\u5c06\u8bf7\u6c42\u53d1\u9001\u5230\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u7531\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u53bb\u9009\u62e9\u76ee\u6807\u670d\u52a1\u5668\u83b7\u53d6\u6570\u636e\u540e\uff0c\u518d\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\uff0c\u6b64\u65f6\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u5916\u5c31\u662f\u4e00\u4e2a\u670d\u52a1\u5668\uff0c\u66b4\u6f0f\u7684\u662f\u4ee3\u7406\u670d\u52a1\u5668\u5730\u5740\u3002 1.3 \u8d1f\u8f7d\u5747\u8861 \u5982\u679c\u8bf7\u6c42\u6570\u8fc7\u5927\uff0c\u5355\u4e2a\u670d\u52a1\u5668\u89e3\u51b3\u4e0d\u4e86\uff0c\u6211\u4eec\u589e\u52a0\u670d\u52a1\u5668\u7684\u6570\u91cf\uff0c\u7136\u540e\u5c06\u8bf7\u6c42\u5206\u53d1\u5230\u5404\u4e2a\u670d\u52a1\u5668\u4e0a\uff0c\u5c06\u539f\u5148\u8bf7\u6c42\u96c6\u4e2d\u5230\u5355\u4e2a\u670d\u52a1\u5668\u7684\u60c5\u51b5\u6539\u4e3a\u8bf7\u6c42\u5206\u53d1\u5230\u591a\u4e2a\u670d\u52a1\u5668\u4e0a\uff0c\u5c31\u662f\u8d1f\u8f7d\u5747\u8861\u3002 1.4 \u52a8\u9759\u5206\u79bb \u4e3a\u4e86\u52a0\u5feb\u670d\u52a1\u5668\u7684\u89e3\u6790\u901f\u5ea6\uff0c\u53ef\u4ee5\u628a\u52a8\u6001\u9875\u9762\u548c\u9759\u6001\u9875\u9762\u4ea4\u7ed9\u4e0d\u540c\u7684\u670d\u52a1\u5668\u6765\u89e3\u6790\uff0c\u52a0\u5feb\u89e3\u6790\u901f\u5ea6\uff0c\u964d\u4f4e\u539f\u6765\u5355\u4e2a\u670d\u52a1\u5668\u7684\u538b\u529b\u3002 \u4e8c Nginx\u7684\u5b89\u88c5 Nginx\u9700\u8981\u51e0\u4e2a\u4f9d\u8d56\u5305\uff0c\u5206\u522b\u662fpcre\uff0copenssl\uff0czlib\uff0c\u5728\u5b89\u88c5\u4e4b\u524d\u9700\u8981\u5148\u5b89\u88c5\u8fd9\u51e0\u4e2a\u4f9d\u8d56\u3002 2.1 \u5b89\u88c5pcre\u4f9d\u8d56 \u4f7f\u7528\u547d\u4ee4\u4e0b\u8f7dpcre\u538b\u7f29\u5305 1wget&nbsp;http:\/\/downloads.sourceforge.net\/project\/pcre\/pcre\/8.37\/pcre-8.37.tar.gz \u767b\u5f55\u540e\u590d\u5236 \u89e3\u538b\u538b\u7f29\u6587\u4ef6 1tar&nbsp;-xvf&nbsp;&nbsp;pcre-8.37.tar.gz \u767b\u5f55\u540e\u590d\u5236 \u8fdb\u5165\u89e3\u538b\u540e\u7684\u540d\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4 1.\/configure \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u7f16\u8bd1\u5b89\u88c5 1make&nbsp;&amp;amp;&amp;amp;&nbsp;make&nbsp;install \u767b\u5f55\u540e\u590d\u5236 \u67e5\u770b\u5b89\u88c5\u7684pcre\u7248\u672c\u53f7 1pcre-config&nbsp;&#8211;version \u767b\u5f55\u540e\u590d\u5236 2.2 \u5b89\u88c5openssl\uff0czlib\u7b49\u4f9d\u8d56 1yum&nbsp;-y&nbsp;install&nbsp;make&nbsp;zlib&nbsp;zlib-devel&nbsp;gcc-c++&nbsp;libtool&nbsp;openssl&nbsp;openssl-devel \u767b\u5f55\u540e\u590d\u5236 2.3 \u5b89\u88c5nginx nginx\u5b98\u7f51\u4e0b\u8f7dnginx\uff0c\u5b98\u7f51\u5730\u5740\uff1ahttps:\/\/nginx.org\/download\/\uff1b \u5c06\u538b\u7f29\u5305\u62d6\u5230\u670d\u52a1\u5668\u4e0a; \u4f7f\u7528\u547d\u4ee4tar -xvf nginx-1.12.2.tar.gz\u89e3\u538b\u538b\u7f29\u5305; \u4f7f\u7528\u547d\u4ee4.\/configure\u68c0\u67e5\uff1b \u4f7f\u7528\u547d\u4ee4make &amp;&amp; make isntall\u7f16\u8bd1\u5b89\u88c5\uff1b \u5b89\u88c5\u6210\u529f\u540e\uff0c\u5728usr\u4f1a\u591a\u51fa\u6765\u4e00\u4e2a\u6587\u4ef6\u5939\uff0clocal\/nginx\uff0c\u5728nginx\u7684sbin\u6587\u4ef6\u5939\u4e0b\u6709\u542f\u52a8\u811a\u672c\u3002 2.4 \u542f\u52a8nginx \u5728\/usr\/local\/nginx\/sbin\u6587\u4ef6\u5939\u4e0b\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-61922","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61922","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=61922"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61922\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=61922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=61922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=61922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}