{"id":15687,"date":"2025-04-18T22:13:03","date_gmt":"2025-04-18T14:13:03","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/15687.html"},"modified":"2025-04-18T22:13:03","modified_gmt":"2025-04-18T14:13:03","slug":"tengine%ef%bc%9a%e9%ab%98%e6%80%a7%e8%83%bdweb-%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8e%e5%8f%8d%e5%90%91%e4%bb%a3%e7%90%86","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/15687.html","title":{"rendered":"Tengine\uff1a\u9ad8\u6027\u80fdWeb \u670d\u52a1\u5668\u4e0e\u53cd\u5411\u4ee3\u7406"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"-toc\" style=\"margin-left:0px\">\n<p id=\"Nginx%E5%92%8CTengine-toc\" style=\"margin-left:0px\">Nginx\u548cTengine<\/p>\n<p id=\"Nginx-toc\" style=\"margin-left:40px\">Nginx<\/p>\n<p id=\"Nginx%E5%92%8Capache%E7%9A%84%E4%BC%98%E7%BC%BA%E7%82%B9-toc\" style=\"margin-left:40px\">Nginx\u548capache\u7684\u4f18\u7f3a\u70b9<\/p>\n<p id=\"nginx%E7%9B%B8%E5%AF%B9%E4%BA%8Eapache%E7%9A%84%E4%BC%98%E7%82%B9%EF%BC%9A-toc\" style=\"margin-left:80px\">nginx\u76f8\u5bf9\u4e8eapache\u7684\u4f18\u70b9&#xff1a;<\/p>\n<p id=\"apache%20%E7%9B%B8%E5%AF%B9%E4%BA%8Enginx%20%E7%9A%84%E4%BC%98%E7%82%B9%EF%BC%9A-toc\" style=\"margin-left:80px\">apache \u76f8\u5bf9\u4e8enginx \u7684\u4f18\u70b9&#xff1a;<\/p>\n<p id=\"Nginx%E8%A7%A3%E5%86%B3%E7%9A%84%E9%97%AE%E9%A2%98-toc\" style=\"margin-left:0px\">Nginx\u89e3\u51b3\u7684\u95ee\u9898<\/p>\n<p id=\"%E5%AE%89%E8%A3%85-toc\" style=\"margin-left:0px\">\u5b89\u88c5<\/p>\n<p id=\"%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C-toc\" style=\"margin-left:40px\">\u51c6\u5907\u5de5\u4f5c<\/p>\n<p id=\"%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F-toc\" style=\"margin-left:80px\">\u64cd\u4f5c\u7cfb\u7edf<\/p>\n<p id=\"Tengine%E4%B8%8B%E8%BD%BD%E5%92%8C%E6%96%87%E6%A1%A3-toc\" style=\"margin-left:80px\">Tengine\u4e0b\u8f7d\u548c\u6587\u6863<\/p>\n<p id=\"Nginx%E5%AE%98%E7%BD%91%E5%92%8C%E6%96%87%E6%A1%A3-toc\" style=\"margin-left:80px\">Nginx\u5b98\u7f51\u548c\u6587\u6863<\/p>\n<p id=\"%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85-toc\" style=\"margin-left:80px\">\u7f16\u8bd1\u5b89\u88c5<\/p>\n<p id=\"%E5%90%AF%E5%8A%A8%E6%9C%8D%E5%8A%A1-toc\" style=\"margin-left:0px\">\u542f\u52a8\u670d\u52a1<\/p>\n<p id=\"%E8%84%9A%E6%9C%AC%E8%87%AA%E5%90%AF%E5%8A%A8-toc\" style=\"margin-left:40px\">\u811a\u672c\u81ea\u542f\u52a8<\/p>\n<p id=\"%E4%BF%AE%E6%94%B9%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%9D%83%E9%99%90-toc\" style=\"margin-left:80px\">\u4fee\u6539\u53ef\u6267\u884c\u6743\u9650<\/p>\n<p id=\"%E5%90%AF%E5%8A%A8%E6%9C%8D%E5%8A%A1-toc\" style=\"margin-left:80px\">\u542f\u52a8\u670d\u52a1<\/p>\n<p id=\"%E8%84%9A%E6%9C%AC%E5%86%85%E5%AE%B9%EF%BC%9A-toc\" style=\"margin-left:80px\">\u811a\u672c\u5185\u5bb9&#xff1a;<\/p>\n<p id=\"Nginx%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90-toc\" style=\"margin-left:0px\">Nginx\u914d\u7f6e\u89e3\u6790<\/p>\n<p id=\"%E5%AE%9A%E4%B9%89Nginx%E8%BF%90%E8%A1%8C%E7%9A%84%E7%94%A8%E6%88%B7%E5%92%8C%E7%94%A8%E6%88%B7%E7%BB%84-toc\" style=\"margin-left:40px\">\u5b9a\u4e49Nginx\u8fd0\u884c\u7684\u7528\u6237\u548c\u7528\u6237\u7ec4<\/p>\n<p id=\"%E8%BF%9B%E7%A8%8B%E6%95%B0-toc\" style=\"margin-left:40px\">\u8fdb\u7a0b\u6570<\/p>\n<p id=\"%E5%85%A8%E5%B1%80%E9%94%99%E8%AF%AF%E6%97%A5%E5%BF%97-toc\" style=\"margin-left:40px\">\u5168\u5c40\u9519\u8bef\u65e5\u5fd7<\/p>\n<p id=\"%E8%BF%9B%E7%A8%8B%E6%96%87%E4%BB%B6-toc\" style=\"margin-left:40px\">\u8fdb\u7a0b\u6587\u4ef6<\/p>\n<p id=\"%E6%89%93%E5%BC%80%E7%9A%84%E6%9C%80%E5%A4%9A%E6%96%87%E4%BB%B6%E6%8F%8F%E8%BF%B0%E7%AC%A6-toc\" style=\"margin-left:40px\">\u6253\u5f00\u7684\u6700\u591a\u6587\u4ef6\u63cf\u8ff0\u7b26<\/p>\n<p id=\"event-toc\" style=\"margin-left:40px\">event<\/p>\n<p id=\"%E5%8D%95%E4%B8%AA%E8%BF%9B%E7%A8%8B%E6%9C%80%E5%A4%A7%E8%BF%9E%E6%8E%A5%E6%95%B0-toc\" style=\"margin-left:80px\">\u5355\u4e2a\u8fdb\u7a0b\u6700\u5927\u8fde\u63a5\u6570<\/p>\n<p id=\"%E6%89%93%E5%BC%80%E6%96%87%E4%BB%B6%E5%8F%A5%E6%9F%84%E6%95%B0%E9%87%8F%E9%99%90%E5%88%B6-toc\" style=\"margin-left:80px\">\u6253\u5f00\u6587\u4ef6\u53e5\u67c4\u6570\u91cf\u9650\u5236<\/p>\n<p id=\"http-toc\" style=\"margin-left:40px\">http<\/p>\n<p id=\"sendfile-toc\" style=\"margin-left:80px\">sendfile<\/p>\n<p id=\"gzip-toc\" style=\"margin-left:80px\">gzip<\/p>\n<p id=\"server-toc\" style=\"margin-left:40px\">server<\/p>\n<p id=\"%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA-toc\" style=\"margin-left:80px\">\u865a\u62df\u4e3b\u673a<\/p>\n<p id=\"location-toc\" style=\"margin-left:160px\">location<\/p>\n<p id=\"location%E9%85%8D%E7%BD%AE%E8%A7%84%E5%88%99-toc\" style=\"margin-left:200px\">location\u914d\u7f6e\u89c4\u5219<\/p>\n<p id=\"IP%E8%AE%BF%E9%97%AE%E6%8E%A7%E5%88%B6-toc\" style=\"margin-left:40px\">IP\u8bbf\u95ee\u63a7\u5236<\/p>\n<p id=\"%E7%94%A8%E6%88%B7%E8%AE%A4%E8%AF%81%E8%AE%BF%E9%97%AE-toc\" style=\"margin-left:40px\">\u7528\u6237\u8ba4\u8bc1\u8bbf\u95ee<\/p>\n<p id=\"httpd-tools-toc\" style=\"margin-left:40px\">httpd-tools<\/p>\n<p id=\"nginx%E8%AE%BF%E9%97%AE%E7%8A%B6%E6%80%81%E7%9B%91%E6%8E%A7-toc\" style=\"margin-left:40px\">nginx\u8bbf\u95ee\u72b6\u6001\u76d1\u63a7<\/p>\n<p id=\"%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86-toc\" style=\"margin-left:40px\">\u53cd\u5411\u4ee3\u7406<\/p>\n<p id=\"%E7%BB%8F%E5%85%B8%E7%9A%84%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E7%BB%93%E6%9E%84-toc\" style=\"margin-left:80px\">\u7ecf\u5178\u7684\u53cd\u5411\u4ee3\u7406\u7ed3\u6784<\/p>\n<p id=\"upstream-toc\" style=\"margin-left:80px\">upstream<\/p>\n<p id=\"weight(%E6%9D%83%E9%87%8D)-toc\" style=\"margin-left:120px\">weight(\u6743\u91cd)<\/p>\n<p id=\"max_conns-toc\" style=\"margin-left:120px\">max_conns<\/p>\n<p id=\"max_fails%E3%80%81%20fail_timeout-toc\" style=\"margin-left:120px\">max_fails\u3001 fail_timeout<\/p>\n<p id=\"%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1%E7%AE%97%E6%B3%95-toc\" style=\"margin-left:120px\">\u8d1f\u8f7d\u5747\u8861\u7b97\u6cd5<\/p>\n<p id=\"%E5%81%A5%E5%BA%B7%E6%A3%80%E6%9F%A5%E6%A8%A1%E5%9D%97-toc\" style=\"margin-left:80px\">\u5065\u5eb7\u68c0\u67e5\u6a21\u5757<\/p>\n<p id=\"session%E5%85%B1%E4%BA%AB-toc\" style=\"margin-left:40px\">session\u5171\u4eab<\/p>\n<p id=\"Memcached-toc\" style=\"margin-left:80px\">Memcached<\/p>\n<p id=\"%E5%AE%89%E8%A3%85-toc\" style=\"margin-left:120px\">\u5b89\u88c5<\/p>\n<p id=\"%E5%90%AF%E5%8A%A8memcached-toc\" style=\"margin-left:120px\">\u542f\u52a8memcached<\/p>\n<p id=\"Nginx%E9%85%8D%E7%BD%AE-toc\" style=\"margin-left:120px\">Nginx\u914d\u7f6e<\/p>\n<p id=\"Tomcat%E9%85%8D%E7%BD%AE-toc\" style=\"margin-left:80px\">Tomcat\u914d\u7f6e<\/p>\n<p id=\"http_proxy%20%E6%9C%AC%E5%9C%B0%E7%A3%81%E7%9B%98%E7%BC%93%E5%AD%98-toc\" style=\"margin-left:80px\">http_proxy \u672c\u5730\u78c1\u76d8\u7f13\u5b58<\/p>\n<p id=\"%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8-toc\" style=\"margin-left:0px\">\u5f00\u673a\u542f\u52a8<\/p>\n<p id=\"%E8%99%9A%E6%8B%9F%E7%9B%AE%E5%BD%95-toc\" style=\"margin-left:0px\">\u865a\u62df\u76ee\u5f55<\/p>\n<p id=\"%E8%87%AA%E5%8A%A8%E7%B4%A2%E5%BC%95-toc\" style=\"margin-left:0px\">\u81ea\u52a8\u7d22\u5f15<\/p>\n<p id=\"%E5%8A%A8%E9%9D%99%E5%88%86%E7%A6%BB-toc\" style=\"margin-left:0px\">\u52a8\u9759\u5206\u79bb<\/p>\n<hr id=\"hr-toc\" \/>\n<h2 id=\"Nginx%E5%92%8CTengine\">Nginx\u548cTengine<\/h2>\n<h3 id=\"Nginx\">Nginx<\/h3>\n<p>Nginx (&#034;engine x&#034;) \u662f\u4e00\u4e2a\u9ad8\u6027\u80fd\u7684 HTTP \u548c \u53cd\u5411\u4ee3\u7406 \u670d\u52a1\u5668&#xff0c;\u4e5f\u662f\u4e00\u4e2a IMAP\/POP3\/SMTP \u4ee3\u7406\u670d\u52a1\u5668\u3002<\/p>\n<p>\u2022\u7b2c\u4e00\u4e2a\u516c\u5f00\u7248\u672c0.1.0\u53d1\u5e03\u4e8e2004\u5e7410\u67084\u65e5\u3002<\/p>\n<p>\u5176\u5c06\u6e90\u4ee3\u7801\u4ee5\u7c7bBSD\u8bb8\u53ef\u8bc1\u7684\u5f62\u5f0f\u53d1\u5e03&#xff0c;\u56e0\u5b83\u7684\u7a33\u5b9a\u6027\u3001\u4e30\u5bcc\u7684\u529f\u80fd\u96c6\u3001\u793a\u4f8b\u914d\u7f6e\u6587\u4ef6\u548c\u4f4e\u7cfb\u7edf\u8d44\u6e90\u7684\u6d88\u8017\u800c\u95fb\u540d<\/p>\n<p>\u5b98\u65b9\u6d4b\u8bd5nginx\u80fd\u591f\u652f\u64915\u4e07\u5e76\u53d1\u94fe\u63a5&#xff0c;\u5e76\u4e14cpu\u3001\u5185\u5b58\u7b49\u8d44\u6e90\u6d88\u8017\u5374\u975e\u5e38\u4f4e&#xff0c;\u8fd0\u884c\u975e\u5e38\u7a33\u5b9a<\/p>\n<p>2011\u5e746\u67081\u65e5&#xff0c;nginx 1.0.4\u53d1\u5e03\u3002<\/p>\n<p>Nginx\u662f\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u7684Web \u670d\u52a1\u5668\/\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u53ca\u7535\u5b50\u90ae\u4ef6&#xff08;IMAP\/POP3&#xff09;\u4ee3\u7406\u670d\u52a1\u5668&#xff0c;\u5e76\u5728\u4e00\u4e2aBSD-like \u534f\u8bae\u4e0b\u53d1\u884c\u3002\u7531\u4fc4\u7f57\u65af\u7684\u7a0b\u5e8f\u8bbe\u8ba1\u5e08Igor Sysoev\u6240\u5f00\u53d1&#xff0c;<\/p>\n<p>\u5176\u7279\u70b9\u662f\u5360\u6709\u5185\u5b58\u5c11&#xff0c;\u5e76\u53d1\u80fd\u529b\u5f3a&#xff0c;\u4e8b\u5b9e\u4e0anginx\u7684\u5e76\u53d1\u80fd\u529b\u786e\u5b9e\u5728\u540c\u7c7b\u578b\u7684\u7f51\u9875\u670d\u52a1\u5668\u4e2d\u8868\u73b0\u8f83\u597d&#xff0c;\u4e2d\u56fd\u5927\u9646\u4f7f\u7528nginx\u7f51\u7ad9\u7528\u6237\u6709&#xff1a;\u65b0\u6d6a\u3001\u7f51\u6613\u3001\u817e\u8baf\u7b49\u3002<\/p>\n<p>\u529f\u80fd&#xff1a;<\/p>\n<ul>\n<li>\n<p>web\u670d\u52a1\u5668<\/p>\n<\/li>\n<li>\n<p>web reverse proxy<\/p>\n<\/li>\n<li>\n<p>smtp reverse proxy<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"Nginx%E5%92%8Capache%E7%9A%84%E4%BC%98%E7%BC%BA%E7%82%B9\">Nginx\u548capache\u7684\u4f18\u7f3a\u70b9<\/h3>\n<h4 id=\"nginx%E7%9B%B8%E5%AF%B9%E4%BA%8Eapache%E7%9A%84%E4%BC%98%E7%82%B9%EF%BC%9A\">nginx\u76f8\u5bf9\u4e8eapache\u7684\u4f18\u70b9&#xff1a;<\/h4>\n<ul>\n<li>\n<p>\u9ad8\u6027\u80fd&#xff1a;Nginx \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u3001\u9ad8\u6027\u80fd\u7684 Web \u670d\u52a1\u5668&#xff0c;\u5728\u5904\u7406\u9759\u6001\u5185\u5bb9\u548c\u9ad8\u5e76\u53d1\u8bf7\u6c42\u65f6\u8868\u73b0\u4f18\u79c0&#xff0c;\u80fd\u591f\u66f4\u6709\u6548\u5730\u5229\u7528\u670d\u52a1\u5668\u8d44\u6e90&#xff0c;\u964d\u4f4e\u670d\u52a1\u5668\u8d1f\u8f7d\u3002<\/p>\n<\/li>\n<li>\n<p>\u9ad8\u5e76\u53d1\u5904\u7406\u80fd\u529b&#xff1a;Nginx \u4f7f\u7528\u4e8b\u4ef6\u9a71\u52a8\u67b6\u6784&#xff0c;\u80fd\u591f\u66f4\u6709\u6548\u5730\u5904\u7406\u5927\u91cf\u5e76\u53d1\u8fde\u63a5&#xff0c;\u9002\u5408\u9ad8\u6d41\u91cf\u7684\u7f51\u7ad9\u548c\u5e94\u7528\u3002<\/p>\n<\/li>\n<li>\n<p>\u5fae\u670d\u52a1\u652f\u6301&#xff1a;Nginx \u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u6a21\u5757&#xff0c;\u53ef\u4ee5\u7528\u4e8e\u53cd\u5411\u4ee3\u7406\u3001\u8d1f\u8f7d\u5747\u8861\u3001\u7f13\u5b58\u7b49&#xff0c;\u652f\u6301\u5fae\u670d\u52a1\u67b6\u6784\u7684\u90e8\u7f72\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f4e\u5185\u5b58\u6d88\u8017&#xff1a;\u76f8\u6bd4\u4e8e Apache&#xff0c;Nginx \u7684\u5185\u5b58\u6d88\u8017\u66f4\u4f4e&#xff0c;\u53ef\u4ee5\u5728\u8f83\u5c11\u7684\u8d44\u6e90\u4e0b\u8fd0\u884c\u66f4\u591a\u7684\u5e76\u53d1\u8fde\u63a5\u3002<\/p>\n<\/li>\n<li>\n<p>\u914d\u7f6e\u7075\u6d3b\u6027&#xff1a;Nginx \u7684\u914d\u7f6e\u6587\u4ef6\u7ed3\u6784\u7b80\u5355\u6e05\u6670&#xff0c;\u652f\u6301\u6a21\u5757\u5316\u7684\u914d\u7f6e\u548c\u7075\u6d3b\u7684\u91cd\u5b9a\u5411\u89c4\u5219&#xff0c;\u65b9\u4fbf\u7ba1\u7406\u5458\u8fdb\u884c\u5b9a\u5236\u5316\u914d\u7f6e\u3002<\/p>\n<\/li>\n<li>\n<p>\u793e\u533a\u6d3b\u8dc3&#xff0c;\u5404\u79cd\u9ad8\u6027\u80fd\u6a21\u5757\u51fa\u54c1\u8fc5\u901f<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"apache%20%E7%9B%B8%E5%AF%B9%E4%BA%8Enginx%20%E7%9A%84%E4%BC%98%E7%82%B9%EF%BC%9A\">apache \u76f8\u5bf9\u4e8enginx \u7684\u4f18\u70b9&#xff1a;<\/h4>\n<ul>\n<li>\n<p>rewrite &#xff0c;\u6bd4nginx \u7684rewrite \u5f3a\u5927<\/p>\n<\/li>\n<li>\n<p>\u6a21\u5757\u8d85\u591a&#xff0c;\u57fa\u672c\u60f3\u5230\u7684\u90fd\u53ef\u4ee5\u627e\u5230<\/p>\n<\/li>\n<li>\n<p>\u5c11bug &#xff0c;nginx \u7684bug \u76f8\u5bf9\u8f83\u591a<\/p>\n<\/li>\n<\/ul>\n<p>Nginx \u914d\u7f6e\u7b80\u6d01, Apache \u590d\u6742<\/p>\n<p>\u6700\u6838\u5fc3\u7684\u533a\u522b\u5728\u4e8eapache\u662f\u540c\u6b65\u591a\u8fdb\u7a0b\u6a21\u578b&#xff0c;\u4e00\u4e2a\u8fde\u63a5\u5bf9\u5e94\u4e00\u4e2a\u8fdb\u7a0b&#xff1b;<\/p>\n<p>nginx\u662f\u5f02\u6b65\u7684&#xff0c;\u591a\u4e2a\u8fde\u63a5&#xff08;\u4e07\u7ea7\u522b&#xff09;\u53ef\u4ee5\u5bf9\u5e94\u4e00\u4e2a\u8fdb\u7a0b<\/p>\n<h2 id=\"Nginx%E8%A7%A3%E5%86%B3%E7%9A%84%E9%97%AE%E9%A2%98\">Nginx\u89e3\u51b3\u7684\u95ee\u9898<\/h2>\n<ul>\n<li>\n<p>\u9ad8\u5e76\u53d1\u5904\u7406&#xff1a;Nginx\u91c7\u7528\u4e86\u4e8b\u4ef6\u9a71\u52a8\u6a21\u578b&#xff0c;\u80fd\u591f\u6709\u6548\u5730\u5904\u7406\u5927\u91cf\u5e76\u53d1\u8bf7\u6c42&#xff0c;\u4e0d\u4f1a\u56e0\u4e3a\u9ad8\u6d41\u91cf\u800c\u5d29\u6e83\u3002<\/p>\n<\/li>\n<li>\n<p>\u53cd\u5411\u4ee3\u7406&#xff1a;Nginx\u53ef\u4ee5\u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668&#xff0c;\u5c06\u8bf7\u6c42\u8f6c\u53d1\u7ed9\u540e\u7aef\u7684\u5e94\u7528\u670d\u52a1\u5668&#xff0c;\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u548c\u63d0\u9ad8\u6027\u80fd\u3002<\/p>\n<\/li>\n<li>\n<p>\u9759\u6001\u8d44\u6e90\u670d\u52a1&#xff1a;Nginx\u5bf9\u9759\u6001\u6587\u4ef6\u7684\u5904\u7406\u6548\u7387\u975e\u5e38\u9ad8&#xff0c;\u53ef\u4ee5\u5feb\u901f\u5730\u63d0\u4f9b\u9759\u6001\u6587\u4ef6\u7684\u8bbf\u95ee\u670d\u52a1&#xff0c;\u51cf\u8f7b\u540e\u7aef\u5e94\u7528\u670d\u52a1\u5668\u7684\u8d1f\u62c5\u3002<\/p>\n<\/li>\n<li>\n<p>\u5b89\u5168\u6027&#xff1a;Nginx\u5177\u6709\u4e30\u5bcc\u7684\u5b89\u5168\u529f\u80fd&#xff0c;\u5305\u62ec\u8bbf\u95ee\u63a7\u5236\u3001\u9632\u6b62DDoS\u653b\u51fb\u3001SSL\/TLS \u52a0\u5bc6\u7b49&#xff0c;\u53ef\u4ee5\u5e2e\u52a9\u4fdd\u62a4\u7f51\u7ad9\u514d\u53d7\u6076\u610f\u653b\u51fb\u3002<\/p>\n<\/li>\n<li>\n<p>\u9ad8\u53ef\u9760\u6027&#xff1a;Nginx\u5177\u6709\u9ad8\u53ef\u9760\u6027\u548c\u7a33\u5b9a\u6027&#xff0c;\u80fd\u591f\u6301\u7eed\u8fd0\u884c\u957f\u65f6\u95f4\u800c\u4e0d\u4f1a\u51fa\u73b0\u95ee\u9898&#xff0c;\u9002\u7528\u4e8e\u5927\u578b\u751f\u4ea7\u73af\u5883\u3002<\/p>\n<\/li>\n<\/ul>\n<h2 id=\"%E5%AE%89%E8%A3%85\">\u5b89\u88c5<\/h2>\n<h3 id=\"%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C\">\u51c6\u5907\u5de5\u4f5c<\/h3>\n<h4 id=\"%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F\">\u64cd\u4f5c\u7cfb\u7edf<\/h4>\n<p>\u6700\u597d\u4f7f\u7528linux\u64cd\u4f5c\u7cfb\u7edf&#xff0c;\u8bfe\u4e0a\u4f7f\u7528VirtualBox\u6216VMware\u865a\u62df\u673a\u642d\u5efacentos6.x\u505a\u5b9e\u9a8c\u3002<\/p>\n<p>\u7cfb\u7edf\u4f9d\u8d56\u7ec4\u4ef6 gcc openssl-devel pcre-devel zlib-devel<\/p>\n<p>\u5b89\u88c5&#xff1a;yum install gcc openssl-devel pcre-devel zlib-devel<\/p>\n<h4 id=\"Tengine%E4%B8%8B%E8%BD%BD%E5%92%8C%E6%96%87%E6%A1%A3\">Tengine\u4e0b\u8f7d\u548c\u6587\u6863<\/h4>\n<p>The Tengine Web Server<\/p>\n<h4 id=\"Nginx%E5%AE%98%E7%BD%91%E5%92%8C%E6%96%87%E6%A1%A3\">Nginx\u5b98\u7f51\u548c\u6587\u6863<\/h4>\n<p>http:\/\/nginx.org<\/p>\n<p>\u4e0a\u4f20Nginx\u538b\u7f29\u5305\u5230\u670d\u52a1\u5668&#xff0c;\u4e00\u822c\u5b89\u88c5\u5728\/usr\/local\u76ee\u5f55\u4e0b<\/p>\n<h4 id=\"%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85\">\u7f16\u8bd1\u5b89\u88c5<\/h4>\n<p>.\/ configure &#8211;prefix&#061;\/\u5b89\u88c5\u8def\u5f84<\/p>\n<p>make &amp;&amp; make install <\/p>\n<h2 id=\"%E5%90%AF%E5%8A%A8%E6%9C%8D%E5%8A%A1\">\u542f\u52a8\u670d\u52a1<\/h2>\n<h3 id=\"%E8%84%9A%E6%9C%AC%E8%87%AA%E5%90%AF%E5%8A%A8\">\u811a\u672c\u81ea\u542f\u52a8<\/h3>\n<p>\u62f7\u8d1d\u9644\u4ef6\u63d0\u4f9b\u7684Nginx\u542f\u52a8\u811a\u672c\u6587\u4ef6\u5185\u5bb9\u5230\/etc\/init.d\/nginx\u8fd9\u4e2a\u6587\u4ef6\u4e2d<\/p>\n<p>\u76ee\u5f55\u4e0b\u5982\u679c\u6ca1\u6709\u8fd9\u4e2a\u6587\u4ef6\u7684\u8bdd\u9700\u8981\u624b\u52a8\u521b\u5efa<\/p>\n<h4 id=\"%E4%BF%AE%E6%94%B9%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%9D%83%E9%99%90\">\u4fee\u6539\u53ef\u6267\u884c\u6743\u9650<\/h4>\n<p>chmod 777 nginx<\/p>\n<h4 id=\"%E5%90%AF%E5%8A%A8%E6%9C%8D%E5%8A%A1\">\u542f\u52a8\u670d\u52a1<\/h4>\n<p>service Nginx start \u542f\u52a8\u670d\u52a1<\/p>\n<p>service Nginx stop \u505c\u6b62<\/p>\n<p>service Nginx status \u72b6\u6001<\/p>\n<p>service Nginx reload \u52a8\u6001\u91cd\u8f7d\u914d\u7f6e\u6587\u4ef6<\/p>\n<h4 id=\"%E8%84%9A%E6%9C%AC%E5%86%85%E5%AE%B9%EF%BC%9A\">\u811a\u672c\u5185\u5bb9&#xff1a;<\/h4>\n<p>#!\/bin\/sh<br \/>\n#<br \/>\n# nginx &#8211; this script starts and stops the nginx daemon<br \/>\n#<br \/>\n# chkconfig:   &#8211; 85 15<br \/>\n# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \\\\<br \/>\n#               proxy and IMAP\/POP3 proxy server<br \/>\n# processname: nginx<br \/>\n# config:      \/etc\/nginx\/nginx.conf<br \/>\n# config:      \/etc\/sysconfig\/nginx<br \/>\n# pidfile:     \/var\/run\/nginx.pid<\/p>\n<p># Source function library.<br \/>\n. \/etc\/rc.d\/init.d\/functions<\/p>\n<p># Source networking configuration.<br \/>\n. \/etc\/sysconfig\/network<\/p>\n<p># Check that networking is up.<br \/>\n[ &#034;$NETWORKING&#034; &#061; &#034;no&#034; ] &amp;&amp; exit 0<\/p>\n<p>nginx&#061;&#034;\/usr\/local\/tengine\/sbin\/nginx&#034;<br \/>\nprog&#061;$(basename $nginx)<\/p>\n<p>NGINX_CONF_FILE&#061;&#034;\/usr\/local\/tengine\/conf\/nginx.conf&#034;<\/p>\n<p>[ -f \/etc\/sysconfig\/nginx ] &amp;&amp; . \/etc\/sysconfig\/nginx<\/p>\n<p>lockfile&#061;\/var\/lock\/subsys\/nginx<\/p>\n<p>make_dirs() {<br \/>\n   # make required directories<br \/>\n   user&#061;&#096;nginx -V 2&gt;&amp;1 | grep &#034;configure arguments:&#034; | sed &#039;s\/[^*]*&#8211;user&#061;\\\\([^ ]*\\\\).*\/\\\\1\/g&#039; -&#096;<br \/>\n   options&#061;&#096;$nginx -V 2&gt;&amp;1 | grep &#039;configure arguments:&#039;&#096;<br \/>\n   for opt in $options; do<br \/>\n       if [ &#096;echo $opt | grep &#039;.*-temp-path&#039;&#096; ]; then<br \/>\n           value&#061;&#096;echo $opt | cut -d &#034;&#061;&#034; -f 2&#096;<br \/>\n           if [ ! -d &#034;$value&#034; ]; then<br \/>\n               # echo &#034;creating&#034; $value<br \/>\n               mkdir -p $value &amp;&amp; chown -R $user $value<br \/>\n           fi<br \/>\n       fi<br \/>\n   done<br \/>\n}<\/p>\n<p>start() {<br \/>\n    [ -x $nginx ] || exit 5<br \/>\n    [ -f $NGINX_CONF_FILE ] || exit 6<br \/>\n    make_dirs<br \/>\n    echo -n $&#034;Starting $prog: &#034;<br \/>\n    daemon $nginx -c $NGINX_CONF_FILE<br \/>\n    retval&#061;$?<br \/>\n    echo<br \/>\n    [ $retval -eq 0 ] &amp;&amp; touch $lockfile<br \/>\n    return $retval<br \/>\n}<\/p>\n<p>stop() {<br \/>\n    echo -n $&#034;Stopping $prog: &#034;<br \/>\n    killproc $prog -QUIT<br \/>\n    retval&#061;$?<br \/>\n    echo<br \/>\n    [ $retval -eq 0 ] &amp;&amp; rm -f $lockfile<br \/>\n    return $retval<br \/>\n}<\/p>\n<p>restart() {<br \/>\n    configtest || return $?<br \/>\n    stop<br \/>\n    sleep 1<br \/>\n    start<br \/>\n}<\/p>\n<p>reload() {<br \/>\n    configtest || return $?<br \/>\n    echo -n $&#034;Reloading $prog: &#034;<br \/>\n    killproc $nginx -HUP<br \/>\n    RETVAL&#061;$?<br \/>\n    echo<br \/>\n}<\/p>\n<p>force_reload() {<br \/>\n    restart<br \/>\n}<\/p>\n<p>configtest() {<br \/>\n  $nginx -t -c $NGINX_CONF_FILE<br \/>\n}<\/p>\n<p>rh_status() {<br \/>\n    status $prog<br \/>\n}<\/p>\n<p>rh_status_q() {<br \/>\n    rh_status &gt;\/dev\/null 2&gt;&amp;1<br \/>\n}<\/p>\n<p>case &#034;$1&#034; in<br \/>\n    start)<br \/>\n        rh_status_q &amp;&amp; exit 0<br \/>\n        $1<br \/>\n        ;;<br \/>\n    stop)<br \/>\n        rh_status_q || exit 0<br \/>\n        $1<br \/>\n        ;;<br \/>\n    restart|configtest)<br \/>\n        $1<br \/>\n        ;;<br \/>\n    reload)<br \/>\n        rh_status_q || exit 7<br \/>\n        $1<br \/>\n        ;;<br \/>\n    force-reload)<br \/>\n        force_reload<br \/>\n        ;;<br \/>\n    status)<br \/>\n        rh_status<br \/>\n        ;;<br \/>\n    condrestart|try-restart)<br \/>\n        rh_status_q || exit 0<br \/>\n            ;;<br \/>\n    *)<br \/>\n        echo $&#034;Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}&#034;<br \/>\n        exit 2<br \/>\nesac<\/p>\n<h2 id=\"Nginx%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90\">Nginx\u914d\u7f6e\u89e3\u6790<\/h2>\n<h3 id=\"%E5%AE%9A%E4%B9%89Nginx%E8%BF%90%E8%A1%8C%E7%9A%84%E7%94%A8%E6%88%B7%E5%92%8C%E7%94%A8%E6%88%B7%E7%BB%84\">\u5b9a\u4e49Nginx\u8fd0\u884c\u7684\u7528\u6237\u548c\u7528\u6237\u7ec4<\/h3>\n<p>user a a;&#096; <\/p>\n<h3 id=\"%E8%BF%9B%E7%A8%8B%E6%95%B0\">\u8fdb\u7a0b\u6570<\/h3>\n<p>\u5efa\u8bae\u8bbe\u7f6e\u4e3a\u7b49\u4e8eCPU\u603b\u6838\u5fc3\u6570\u3002<\/p>\n<p>worker_processes 12;<\/p>\n<h3 id=\"%E5%85%A8%E5%B1%80%E9%94%99%E8%AF%AF%E6%97%A5%E5%BF%97\">\u5168\u5c40\u9519\u8bef\u65e5\u5fd7<\/h3>\n<p>\u5168\u5c40\u9519\u8bef\u65e5\u5fd7\u5b9a\u4e49\u7c7b\u578b&#xff0c;[ debug | info | notice | warn | error | crit ]<\/p>\n<p>error_log \/var\/log\/nginx\/error.log info;<\/p>\n<h3 id=\"%E8%BF%9B%E7%A8%8B%E6%96%87%E4%BB%B6\">\u8fdb\u7a0b\u6587\u4ef6<\/h3>\n<p>pid \/var\/run\/nginx.pid;<\/p>\n<h3 id=\"%E6%89%93%E5%BC%80%E7%9A%84%E6%9C%80%E5%A4%9A%E6%96%87%E4%BB%B6%E6%8F%8F%E8%BF%B0%E7%AC%A6\">\u6253\u5f00\u7684\u6700\u591a\u6587\u4ef6\u63cf\u8ff0\u7b26<\/h3>\n<p>\u4e00\u4e2anginx\u8fdb\u7a0b\u6253\u5f00\u7684\u6700\u591a\u6587\u4ef6\u63cf\u8ff0\u7b26\u6570\u76ee&#xff0c;\u7406\u8bba\u503c\u5e94\u8be5\u662f\u6700\u591a\u6253\u5f00\u6587\u4ef6\u6570&#xff08;\u7cfb\u7edf\u7684\u503culimit -n&#xff09;\u4e0enginx\u8fdb\u7a0b\u6570\u76f8\u9664&#xff0c;\u4f46\u662fnginx\u5206\u914d\u8bf7\u6c42\u5e76\u4e0d\u5747\u5300&#xff0c;\u6240\u4ee5\u5efa\u8bae\u4e0eulimit -n\u7684\u503c\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<p>worker_rlimit_nofile 65535;<\/p>\n<h3 id=\"event\">event<\/h3>\n<h4 id=\"%E5%8D%95%E4%B8%AA%E8%BF%9B%E7%A8%8B%E6%9C%80%E5%A4%A7%E8%BF%9E%E6%8E%A5%E6%95%B0\">\u5355\u4e2a\u8fdb\u7a0b\u6700\u5927\u8fde\u63a5\u6570<\/h4>\n<p>\u5e76\u53d1\u603b\u6570\u662f worker_processes \u548c worker_connections \u7684\u4e58\u79ef<\/p>\n<p>\u5373 max_clients &#061; worker_processes * worker_connections<\/p>\n<p>\u5728\u8bbe\u7f6e\u4e86\u53cd\u5411\u4ee3\u7406\u7684\u60c5\u51b5\u4e0b&#xff0c;max_clients &#061; worker_processes * worker_connections \/ 4 \u4e3a\u4ec0\u4e48 \u4e3a\u4ec0\u4e48\u4e0a\u9762\u53cd\u5411\u4ee3\u7406\u8981\u9664\u4ee54&#xff0c;\u5e94\u8be5\u8bf4\u662f\u4e00\u4e2a\u7ecf\u9a8c\u503c\u6839\u636e\u4ee5\u4e0a\u6761\u4ef6&#xff0c;\u6b63\u5e38\u60c5\u51b5\u4e0b\u7684Nginx Server\u53ef\u4ee5\u5e94\u4ed8\u7684\u6700\u5927\u8fde\u63a5\u6570\u4e3a&#xff1a;4 * 8000 &#061; 32000worker_connections \u503c\u7684\u8bbe\u7f6e\u8ddf\u7269\u7406\u5185\u5b58\u5927\u5c0f\u6709\u5173<\/p>\n<p>\u56e0\u4e3a\u5e76\u53d1\u53d7IO\u7ea6\u675f&#xff0c;max_clients\u7684\u503c\u987b\u5c0f\u4e8e\u7cfb\u7edf\u53ef\u4ee5\u6253\u5f00\u7684\u6700\u5927\u6587\u4ef6\u6570<\/p>\n<p>\u5de5\u4f5c\u6a21\u5f0f\u4e0e\u8fde\u63a5\u6570\u4e0a\u9650<br \/>\nevents<br \/>\n{<br \/>\n\u53c2\u8003\u4e8b\u4ef6\u6a21\u578b&#xff0c;use [ kqueue | rtsig | epoll | \/dev\/poll | select | poll ]; epoll\u6a21\u578b\u662fLinux 2.6\u4ee5\u4e0a\u7248\u672c\u5185\u6838\u4e2d\u7684\u9ad8\u6027\u80fd\u7f51\u7edcI\/O\u6a21\u578b&#xff0c;\u5982\u679c\u8dd1\u5728FreeBSD\u4e0a\u9762&#xff0c;\u5c31\u7528kqueue\u6a21\u578b\u3002<br \/>\nuse epoll;<br \/>\n\u5355\u4e2a\u8fdb\u7a0b\u6700\u5927\u8fde\u63a5\u6570&#xff08;\u6700\u5927\u8fde\u63a5\u6570&#061;\u8fde\u63a5\u6570*\u8fdb\u7a0b\u6570&#xff09;<br \/>\nworker_connections 65535;<br \/>\n}<\/p>\n<p>\u53ef\u4ee5\u6253\u5f00\u7684\u6587\u4ef6\u53e5\u67c4\u6570\u662f\u591a\u5c11<\/p>\n<p>\u2013$ cat \/proc\/sys\/fs\/file-max<\/p>\n<p>\u8f93\u51fa&#xff1a;97320<\/p>\n<p>\u5e76\u53d1\u8fde\u63a5\u603b\u6570\u5c0f\u4e8e\u7cfb\u7edf\u53ef\u4ee5\u6253\u5f00\u7684\u6587\u4ef6\u53e5\u67c4\u603b\u6570&#xff0c;\u8fd9\u6837\u5c31\u5728\u64cd\u4f5c\u7cfb\u7edf\u53ef\u4ee5\u627f\u53d7\u7684\u8303\u56f4\u4e4b\u5185<\/p>\n<p>\u6240\u4ee5&#xff0c;worker_connections \u7684\u503c\u9700\u6839\u636e worker_processes \u8fdb\u7a0b\u6570\u76ee\u548c\u7cfb\u7edf\u53ef\u4ee5\u6253\u5f00\u7684\u6700\u5927\u6587\u4ef6\u603b\u6570\u8fdb\u884c\u9002\u5f53\u5730\u8fdb\u884c\u8bbe\u7f6e,\u4f7f\u5f97\u5e76\u53d1\u603b\u6570\u5c0f\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u53ef\u4ee5\u6253\u5f00\u7684\u6700\u5927\u6587\u4ef6\u6570\u76ee<\/p>\n<p>\u2013 # \u5176\u5b9e\u8d28\u4e5f\u5c31\u662f\u6839\u636e\u4e3b\u673a\u7684\u7269\u7406CPU\u548c\u5185\u5b58\u8fdb\u884c\u914d\u7f6e<\/p>\n<p>\u5f53\u7136&#xff0c;\u7406\u8bba\u4e0a\u7684\u5e76\u53d1\u603b\u6570\u53ef\u80fd\u4f1a\u548c\u5b9e\u9645\u6709\u6240\u504f\u5dee&#xff0c;\u56e0\u4e3a\u4e3b\u673a\u8fd8\u6709\u5176\u4ed6\u7684\u5de5\u4f5c\u8fdb\u7a0b\u9700\u8981\u6d88\u8017\u7cfb\u7edf\u8d44\u6e90\u3002<\/p>\n<p>\u67e5\u770b\u7cfb\u7edf\u9650\u5236 ulimit -a<\/p>\n<h4 id=\"%E6%89%93%E5%BC%80%E6%96%87%E4%BB%B6%E5%8F%A5%E6%9F%84%E6%95%B0%E9%87%8F%E9%99%90%E5%88%B6\" style=\"background-color:transparent\">\u6253\u5f00\u6587\u4ef6\u53e5\u67c4\u6570\u91cf\u9650\u5236<\/h4>\n<p>\u662fLinux\u64cd\u4f5c\u7cfb\u7edf\u5bf9\u4e00\u4e2a\u8fdb\u7a0b\u6253\u5f00\u7684\u6587\u4ef6\u53e5\u67c4\u6570\u91cf\u7684\u9650\u5236(\u4e5f\u5305\u542b\u6253\u5f00\u7684SOCKET\u6570\u91cf&#xff0c;\u53ef\u5f71\u54cdMySQL\u7684\u5e76\u53d1\u8fde\u63a5\u6570\u76ee)<\/p>\n<p>\u7cfb\u7edf\u603b\u9650\u5236&#xff1a; \/proc\/sys\/fs\/file-max \u5f53\u524d\u4f7f\u7528\u53e5\u67c4\u6570&#xff1a;\/proc\/sys\/fs\/file-nr<\/p>\n<p>\u4fee\u6539\u53e5\u67c4\u6570&#xff1a;ulimit -SHn 65535<\/p>\n<h3 id=\"http\">http<\/h3>\n<\/p>\n<p>include mime.types; #\u6587\u4ef6\u6269\u5c55\u540d\u4e0e\u6587\u4ef6\u7c7b\u578b\u6620\u5c04\u8868<\/p>\n<p>default_type application\/octet-stream; #\u9ed8\u8ba4\u6587\u4ef6\u7c7b\u578b<\/p>\n<p>charset utf-8; #\u9ed8\u8ba4\u7f16\u7801<\/p>\n<p>client_header_buffer_size 32k; #\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f\u9650\u5236<\/p>\n<h4 id=\"sendfile\">sendfile<\/h4>\n<p>sendfile on; #\u5f00\u542f\u9ad8\u6548\u6587\u4ef6\u4f20\u8f93\u6a21\u5f0f&#xff0c;sendfile\u6307\u4ee4\u6307\u5b9anginx\u662f\u5426\u8c03\u7528sendfile\u51fd\u6570\u6765\u8f93\u51fa\u6587\u4ef6&#xff0c;\u5bf9\u4e8e\u666e\u901a\u5e94\u7528\u8bbe\u4e3a on&#xff0c;\u5982\u679c\u7528\u6765\u8fdb\u884c\u4e0b\u8f7d\u7b49\u5e94\u7528\u78c1\u76d8IO\u91cd\u8d1f\u8f7d\u5e94\u7528&#xff0c;\u53ef\u8bbe\u7f6e\u4e3aoff&#xff0c;\u4ee5\u5e73\u8861\u78c1\u76d8\u4e0e\u7f51\u7edcI\/O\u5904\u7406\u901f\u5ea6&#xff0c;\u964d\u4f4e\u7cfb\u7edf\u7684\u8d1f\u8f7d\u3002\u6ce8\u610f&#xff1a;\u5982\u679c\u56fe\u7247\u663e\u793a\u4e0d\u6b63\u5e38\u628a\u8fd9\u4e2a\u6539\u6210off\u3002<\/p>\n<p>sendfile()\u8fd8\u80fd\u591f\u7528\u6765\u5728\u4e24\u4e2a\u6587\u4ef6\u5939\u4e4b\u95f4\u79fb\u52a8\u6570\u636e<\/p>\n<p>tcp_nopush \u5728linux\/Unix\u7cfb\u7edf\u4e2d\u4f18\u5316tcp\u6570\u636e\u4f20\u8f93&#xff0c;\u4ec5\u5728sendfile\u5f00\u542f\u65f6\u6709\u6548<\/p>\n<p>autoindex on;#\u5f00\u542f\u76ee\u5f55\u5217\u8868\u8bbf\u95ee&#xff0c;\u5408\u9002\u4e0b\u8f7d\u670d\u52a1\u5668&#xff0c;\u9ed8\u8ba4\u5173\u95ed\u3002<\/p>\n<p>keepalive_timeout 120;#\u957f\u8fde\u63a5\u8d85\u65f6\u65f6\u95f4&#xff0c;\u5355\u4f4d\u662f\u79d2<\/p>\n<h4 id=\"gzip\">gzip<\/h4>\n<p>gzip on; \u5f00\u542fgzip\u538b\u7f29\u8f93\u51fa<\/p>\n<p>gzip_min_length 1k; \u8bbe\u7f6e\u5141\u8bb8\u538b\u7f29\u7684\u9875\u9762\u6700\u5c0f\u5b57\u8282\u6570&#xff0c;\u9875\u9762\u5b57\u8282\u6570\u4eceheader\u5934\u5f97content-length\u4e2d\u8fdb\u884c\u83b7\u53d6\u3002\u9ed8\u8ba4\u503c\u662f0&#xff0c;\u4e0d\u7ba1\u9875\u9762\u591a\u5927\u90fd\u538b\u7f29\u3002\u5efa\u8bae\u8bbe\u7f6e\u6210\u5927\u4e8e2k\u7684\u5b57\u8282\u6570&#xff0c;\u5c0f\u4e8e2k\u53ef\u80fd\u4f1a\u8d8a\u538b\u8d8a\u5927\u3002<\/p>\n<p>gzip_buffers 4 16k; \u8bbe\u7f6e\u7cfb\u7edf\u83b7\u53d6\u51e0\u4e2a\u5355\u4f4d\u7684\u7f13\u5b58\u7528\u4e8e\u5b58\u50a8gzip\u7684\u538b\u7f29\u7ed3\u679c\u6570\u636e\u6d41\u3002 \u4f8b\u5982 4 4k \u4ee3\u8868\u4ee54k\u4e3a\u5355\u4f4d&#xff0c;\u6309\u7167\u539f\u59cb\u6570\u636e\u5927\u5c0f\u4ee54k\u4e3a\u5355\u4f4d\u76844\u500d\u7533\u8bf7\u5185\u5b58\u3002 4 8k \u4ee3\u8868\u4ee58k\u4e3a\u5355\u4f4d&#xff0c;\u6309\u7167\u539f\u59cb\u6570\u636e\u5927\u5c0f\u4ee58k\u4e3a\u5355\u4f4d\u76844\u500d\u7533\u8bf7\u5185\u5b58\u3002 \u5982\u679c\u6ca1\u6709\u8bbe\u7f6e&#xff0c;\u9ed8\u8ba4\u503c\u662f\u7533\u8bf7\u8ddf\u539f\u59cb\u6570\u636e\u76f8\u540c\u5927\u5c0f\u7684\u5185\u5b58\u7a7a\u95f4\u53bb\u5b58\u50a8gzip\u538b\u7f29\u7ed3\u679c\u3002<\/p>\n<p>gzip_http_version 1.0;\u538b\u7f29\u7248\u672c&#xff08;\u9ed8\u8ba41.1&#xff0c;\u524d\u7aef\u5982\u679c\u662fsquid2.5\u8bf7\u4f7f\u75281.0&#xff09;<\/p>\n<p>gzip_comp_level 2; \u538b\u7f29\u7ea7\u522b&#xff0c;1-10&#xff0c;\u6570\u5b57\u8d8a\u5927\u538b\u7f29\u7684\u8d8a\u597d&#xff0c;\u4e5f\u8d8a\u5360\u7528CPU\u65f6\u95f4<\/p>\n<p>gzip_types text\/plain application\/x-javascript text\/css application\/xml; #\u538b\u7f29\u7c7b\u578b&#xff0c;\u9ed8\u8ba4\u5c31\u5df2\u7ecf\u5305\u542btext\/html&#xff0c;\u6240\u4ee5\u4e0b\u9762\u5c31\u4e0d\u7528\u518d\u5199\u4e86&#xff0c;\u5199\u4e0a\u53bb\u4e5f\u4e0d\u4f1a\u6709\u95ee\u9898&#xff0c;\u4f46\u662f\u4f1a\u6709\u4e00\u4e2awarn\u3002<\/p>\n<p>\u9ed8\u8ba4\u503c: gzip_types text\/html (\u9ed8\u8ba4\u4e0d\u5bf9js\/css\u6587\u4ef6\u8fdb\u884c\u538b\u7f29)<\/p>\n<p>\u538b\u7f29\u7c7b\u578b&#xff0c;\u5339\u914dMIME\u7c7b\u578b\u8fdb\u884c\u538b\u7f29<\/p>\n<p>\u8bbe\u7f6e\u54ea\u538b\u7f29\u79cd\u6587\u672c\u6587\u4ef6\u53ef\u53c2\u8003 conf\/mime.types<\/p>\n<p>gzip_disable &#034;MSIE [1-6]\\\\.&#034;;E6\u53ca\u4ee5\u4e0b\u7981\u6b62\u538b\u7f29<\/p>\n<p>gzip_vary on;\u7ed9CDN\u548c\u4ee3\u7406\u670d\u52a1\u5668\u4f7f\u7528&#xff0c;\u9488\u5bf9\u76f8\u540curl&#xff0c;\u53ef\u4ee5\u6839\u636e\u5934\u4fe1\u606f\u8fd4\u56de\u538b\u7f29\u548c\u975e\u538b\u7f29\u526f\u672c<\/p>\n<h3 id=\"server\">server<\/h3>\n<p>listen 80; \u76d1\u542c\u7aef\u53e3 server_name www.mashibing.com mashibing.com; \u57df\u540d\u53ef\u4ee5\u6709\u591a\u4e2a&#xff0c;\u7528\u7a7a\u683c\u9694\u5f00<\/p>\n<p>charset koi8-r; \u7f16\u7801\u96c6<\/p>\n<p>\u65e5\u5fd7\u76f8\u5173<br \/>\naccess_log  &#034;pipe:rollback logs\/host.access_log interval&#061;1d baknum&#061;7 maxsize&#061;2G&#034;  main; <\/p>\n<p>index index.html index.htm index.jsp; \u9ed8\u8ba4\u9875 root \/data\/a\/ha97; \u4e3b\u76ee\u5f55<\/p>\n<h4 id=\"%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA\">\u865a\u62df\u4e3b\u673a<\/h4>\n<p>\u865a\u62df\u4e3b\u673a\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u8f6f\u786c\u4ef6\u6280\u672f&#xff0c;\u5b83\u53ef\u4ee5\u5c06\u7f51\u7edc\u4e0a\u7684\u6bcf\u4e00\u53f0\u8ba1\u7b97\u673a\u5206\u6210\u591a\u4e2a\u865a\u62df\u4e3b\u673a&#xff0c;\u6bcf\u4e2a\u865a\u62df\u4e3b\u673a\u53ef\u4ee5\u72ec\u7acb\u5bf9\u5916\u63d0\u4f9bwww\u670d\u52a1&#xff0c;\u8fd9\u6837\u5c31\u53ef\u4ee5\u5b9e\u73b0\u4e00\u53f0\u4e3b\u673a\u5bf9\u5916\u63d0\u4f9b\u591a\u4e2aweb\u670d\u52a1&#xff0c;\u6bcf\u4e2a\u865a\u62df\u4e3b\u673a\u4e4b\u95f4\u662f\u72ec\u7acb\u7684&#xff0c;\u4e92\u4e0d\u5f71\u54cd\u7684<\/p>\n<\/p>\n<p>\u901a\u8fc7nginx\u53ef\u4ee5\u5b9e\u73b0\u865a\u62df\u4e3b\u673a\u7684\u914d\u7f6e&#xff0c;nginx\u652f\u6301\u4e09\u79cd\u7c7b\u578b\u7684\u865a\u62df\u4e3b\u673a\u914d\u7f6e<\/p>\n<ul>\n<li>\n<p>\u57fa\u4e8eip\u7684\u865a\u62df\u4e3b\u673a&#xff0c; &#xff08;\u4e00\u5757\u4e3b\u673a\u7ed1\u5b9a\u591a\u4e2aip\u5730\u5740&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u57fa\u4e8e\u57df\u540d\u7684\u865a\u62df\u4e3b\u673a&#xff08;servername&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u57fa\u4e8e\u7aef\u53e3\u7684\u865a\u62df\u4e3b\u673a&#xff08;listen\u5982\u679c\u4e0d\u5199ip\u7aef\u53e3\u6a21\u5f0f&#xff09;<\/p>\n<\/li>\n<\/ul>\n<p>http{<br \/>\nserver{<br \/>\n#\u8868\u793a\u4e00\u4e2a\u865a\u62df\u4e3b\u673a<br \/>\n}<br \/>\n} <\/p>\n<h6 id=\"location\">location<\/h6>\n<p>\u6620\u5c04\/\u865a\u62df\u76ee\u5f55<\/p>\n<p>location &#061; \/ {<br \/>\n    [ configuration A ]<br \/>\n}<\/p>\n<p>location \/ {<br \/>\n    [ configuration B ]<br \/>\n}<\/p>\n<p>location \/documents\/ {<br \/>\n    [ configuration C ]<br \/>\n}<\/p>\n<p>location ^~ \/images\/ {<br \/>\n    [ configuration D ]<br \/>\n}<\/p>\n<p>location ~* \\\\.(gif|jpg|jpeg)$ {<br \/>\n    [ configuration E ]<br \/>\n} <\/p>\n<p>location [ &#061; | ~ | ~* | ^~ ] uri { &#8230; }<\/p>\n<p>location URI {} \u5bf9\u5f53\u524d\u8def\u5f84\u53ca\u5b50\u8def\u5f84\u4e0b\u7684\u6240\u6709\u5bf9\u8c61\u90fd\u751f\u6548&#xff1b;<\/p>\n<p>location &#061; URI {} \u6ce8\u610fURL\u6700\u597d\u4e3a\u5177\u4f53\u8def\u5f84\u3002 \u7cbe\u786e\u5339\u914d\u6307\u5b9a\u7684\u8def\u5f84&#xff0c;\u4e0d\u5305\u62ec\u5b50\u8def\u5f84&#xff0c;\u56e0\u6b64&#xff0c;\u53ea\u5bf9\u5f53\u524d\u8d44\u6e90\u751f\u6548&#xff1b;<\/p>\n<p>location ~ URI {} location ~* URI {} \u6a21\u5f0f\u5339\u914dURI&#xff0c;\u6b64\u5904\u7684URI\u53ef\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f&#xff0c;~\u533a\u5206\u5b57\u7b26\u5927\u5c0f\u5199&#xff0c;~*\u4e0d\u533a\u5206\u5b57\u7b26\u5927\u5c0f\u5199&#xff1b;<\/p>\n<p>location ^~ URI {} \u7981\u7528\u6b63\u5219\u8868\u8fbe\u5f0f<\/p>\n<p>\u4f18\u5148\u7ea7&#xff1a;&#061; &gt; ^~ &gt; ~|~* &gt; \/|\/dir\/<\/p>\n<h6 id=\"location%E9%85%8D%E7%BD%AE%E8%A7%84%E5%88%99\">location\u914d\u7f6e\u89c4\u5219<\/h6>\n<p>location \u7684\u6267\u884c\u903b\u8f91\u8ddf location \u7684\u7f16\u8f91\u987a\u5e8f\u65e0\u5173\u3002 \u77eb\u6b63&#xff1a;\u8fd9\u53e5\u8bdd\u4e0d\u5168\u5bf9&#xff0c;\u201c\u666e\u901a location \u201d\u7684\u5339\u914d\u89c4\u5219\u662f\u201c\u6700\u5927\u524d\u7f00\u201d&#xff0c;\u56e0\u6b64\u201c\u666e\u901a location \u201d\u7684\u786e\u4e0e location \u7f16\u8f91\u987a\u5e8f\u65e0\u5173&#xff1b;<\/p>\n<p>\u4f46\u662f\u201c\u6b63\u5219 location \u201d\u7684\u5339\u914d\u89c4\u5219\u662f\u201c\u987a\u5e8f\u5339\u914d&#xff0c;\u4e14\u53ea\u8981\u5339\u914d\u5230\u7b2c\u4e00\u4e2a\u5c31\u505c\u6b62\u540e\u9762\u7684\u5339\u914d\u201d&#xff1b;<\/p>\n<p>\u201c\u666e\u901alocation \u201d\u4e0e\u201c\u6b63\u5219 location \u201d\u4e4b\u95f4\u7684\u5339\u914d\u987a\u5e8f\u662f&#xff1f;\u5148\u5339\u914d\u666e\u901a location &#xff0c;\u518d\u201c\u8003\u8651\u201d\u5339\u914d\u6b63\u5219 location \u3002<\/p>\n<p>\u6ce8\u610f\u8fd9\u91cc\u7684\u201c\u8003\u8651\u201d\u662f\u201c\u53ef\u80fd\u201d\u7684\u610f\u601d&#xff0c;\u4e5f\u5c31\u662f\u8bf4\u5339\u914d\u5b8c\u201c\u666e\u901a location \u201d\u540e&#xff0c;\u6709\u7684\u65f6\u5019\u9700\u8981\u7ee7\u7eed\u5339\u914d\u201c\u6b63\u5219 location \u201d&#xff0c;\u6709\u7684\u65f6\u5019\u5219\u4e0d\u9700\u8981\u7ee7\u7eed\u5339\u914d\u201c\u6b63\u5219 location \u201d\u3002\u4e24\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u4e0d\u9700\u8981\u7ee7\u7eed\u5339\u914d\u6b63\u5219 location &#xff1a;<\/p>\n<ul>\n<li>\n<p>&#xff08; 1 &#xff09;\u5f53\u666e\u901a location \u524d\u9762\u6307\u5b9a\u4e86\u201c ^~ \u201d&#xff0c;\u7279\u522b\u544a\u8bc9 Nginx \u672c\u6761\u666e\u901a location \u4e00\u65e6\u5339\u914d\u4e0a&#xff0c;\u5219\u4e0d\u9700\u8981\u7ee7\u7eed\u6b63\u5219\u5339\u914d&#xff1b;<\/p>\n<\/li>\n<li>\n<p>&#xff08; 2 &#xff09;\u5f53\u666e\u901alocation \u6070\u597d\u4e25\u683c\u5339\u914d\u4e0a&#xff0c;\u4e0d\u662f\u6700\u5927\u524d\u7f00\u5339\u914d&#xff0c;\u5219\u4e0d\u518d\u7ee7\u7eed\u5339\u914d\u6b63\u5219<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"IP%E8%AE%BF%E9%97%AE%E6%8E%A7%E5%88%B6\">IP\u8bbf\u95ee\u63a7\u5236<\/h3>\n<p>location  {<br \/>\n   deny  IP \/IP\u6bb5<br \/>\n   deny  192.168.1.101;<br \/>\n   allow 192.168.1.0\/24;192.168.0.0\/16;192.0.0.0\/8<br \/>\n}<\/p>\n<h3 id=\"%E7%94%A8%E6%88%B7%E8%AE%A4%E8%AF%81%E8%AE%BF%E9%97%AE\" style=\"background-color:transparent\">\u7528\u6237\u8ba4\u8bc1\u8bbf\u95ee<\/h3>\n<p>\u6a21\u5757ngx_http_auth_basic_module \u5141\u8bb8\u4f7f\u7528\u201cHTTP\u57fa\u672c\u8ba4\u8bc1\u201d\u534f\u8bae\u9a8c\u8bc1\u7528\u6237\u540d\u548c\u5bc6\u7801\u6765\u9650\u5236\u5bf9\u8d44\u6e90\u7684\u8bbf\u95ee\u3002<\/p>\n<p>        location ~ (.*)\\\\.avi$ {<br \/>\n                 auth_basic  &#034;closed site&#034;;<br \/>\n                 auth_basic_user_file conf\/users;<br \/>\n        }<\/p>\n<h3 id=\"httpd-tools\">httpd-tools<\/h3>\n<p>yum install httpd<\/p>\n<p>htpasswd -c -d \/usr\/local\/users zhangyang <\/p>\n<h3 id=\"nginx%E8%AE%BF%E9%97%AE%E7%8A%B6%E6%80%81%E7%9B%91%E6%8E%A7\">nginx\u8bbf\u95ee\u72b6\u6001\u76d1\u63a7<\/h3>\n<p>location \/basic_status {<br \/>\n    stub_status on;<br \/>\n} <\/p>\n<h3 id=\"%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86\">\u53cd\u5411\u4ee3\u7406<\/h3>\n<p>\u901a\u5e38\u7684\u4ee3\u7406\u670d\u52a1\u5668&#xff0c;\u53ea\u7528\u4e8e\u4ee3\u7406\u5185\u90e8\u7f51\u7edc\u5bf9Internet\u7684\u8fde\u63a5\u8bf7\u6c42&#xff0c;\u5ba2\u6237\u673a\u5fc5\u987b\u6307\u5b9a\u4ee3\u7406\u670d\u52a1\u5668,\u5e76\u5c06\u672c\u6765\u8981\u76f4\u63a5\u53d1\u9001\u5230Web\u670d\u52a1\u5668\u4e0a\u7684http\u8bf7\u6c42\u53d1\u9001\u5230\u4ee3\u7406\u670d\u52a1\u5668\u4e2d\u7531\u4ee3\u7406\u670d\u52a1\u5668\u5411Internet\u4e0a\u7684web\u670d\u52a1\u5668\u53d1\u8d77\u8bf7\u6c42&#xff0c;\u6700\u7ec8\u8fbe\u5230\u5ba2\u6237\u673a\u4e0a\u7f51\u7684\u76ee\u7684\u3002<\/p>\n<p>\u53cd\u5411\u4ee3\u7406&#xff08;Reverse Proxy&#xff09;\u65b9\u5f0f\u662f\u6307\u4ee5\u4ee3\u7406\u670d\u52a1\u5668\u6765\u63a5\u53d7internet\u4e0a\u7684\u8fde\u63a5\u8bf7\u6c42&#xff0c;\u7136\u540e\u5c06\u8bf7\u6c42\u8f6c\u53d1\u7ed9\u5185\u90e8\u7f51\u7edc\u4e0a\u7684\u670d\u52a1\u5668&#xff0c;\u5e76\u5c06\u4ece\u670d\u52a1\u5668\u4e0a\u5f97\u5230\u7684\u7ed3\u679c\u8fd4\u56de\u7ed9internet\u4e0a\u8bf7\u6c42\u8fde\u63a5\u7684\u5ba2\u6237\u7aef&#xff0c;\u6b64\u65f6\u4ee3\u7406\u670d\u52a1\u5668\u5bf9\u5916\u5c31\u8868\u73b0\u4e3a\u4e00\u4e2a\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668<\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"267\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418141301-68025dede1fbe.png\" width=\"427\" \/><\/p>\n<h4 id=\"%E7%BB%8F%E5%85%B8%E7%9A%84%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E7%BB%93%E6%9E%84\">\u7ecf\u5178\u7684\u53cd\u5411\u4ee3\u7406\u7ed3\u6784<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"300\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418141302-68025dee069c4.png\" width=\"462\" \/><\/p>\n<p>Proxy_pass http:\/\/192.168.43.110\/<\/p>\n<p>301\u91cd\u5b9a\u5411\u95ee\u9898<\/p>\n<h4 id=\"upstream\" style=\"background-color:transparent\">upstream<\/h4>\n<p>\u53cd\u5411\u4ee3\u7406\u914d\u5408upstream\u4f7f\u7528<\/p>\n<p>  upstream httpds {<br \/>\n    server 192.168.50.152:80;<br \/>\n    server 192.168.50.153:80;<br \/>\n} <\/p>\n<h5 id=\"weight(%E6%9D%83%E9%87%8D)\">weight(\u6743\u91cd)<\/h5>\n<p>\u6307\u5b9a\u8f6e\u8be2\u51e0\u7387&#xff0c;weight\u548c\u8bbf\u95ee\u6bd4\u7387\u6210\u6b63\u6bd4&#xff0c;\u7528\u4e8e\u540e\u7aef\u670d\u52a1\u5668\u6027\u80fd\u4e0d\u5747\u7684\u60c5\u51b5\u3002<\/p>\n<p>upstream httpds {<br \/>\n    server 127.0.0.1:8050       weight&#061;10 down;<br \/>\n    server 127.0.0.1:8060       weight&#061;1;<br \/>\n     server 127.0.0.1:8060      weight&#061;1 backup;<br \/>\n} <\/p>\n<ul>\n<li>\n<p>down&#xff1a;\u8868\u793a\u5f53\u524d\u7684server\u6682\u65f6\u4e0d\u53c2\u4e0e\u8d1f\u8f7d<\/p>\n<\/li>\n<li>\n<p>weight&#xff1a;\u9ed8\u8ba4\u4e3a1.weight\u8d8a\u5927&#xff0c;\u8d1f\u8f7d\u7684\u6743\u91cd\u5c31\u8d8a\u5927\u3002<\/p>\n<\/li>\n<li>\n<p>backup&#xff1a; \u5176\u5b83\u6240\u6709\u7684\u975ebackup\u673a\u5668down\u6216\u8005\u5fd9\u7684\u65f6\u5019&#xff0c;\u8bf7\u6c42backup\u673a\u5668\u3002<\/p>\n<\/li>\n<\/ul>\n<h5 id=\"max_conns\">max_conns<\/h5>\n<p>\u53ef\u4ee5\u6839\u636e\u670d\u52a1\u7684\u597d\u574f\u6765\u8bbe\u7f6e\u6700\u5927\u8fde\u63a5\u6570&#xff0c;\u9632\u6b62\u6302\u6389&#xff0c;\u6bd4\u59821000&#xff0c;\u6211\u4eec\u53ef\u4ee5\u8bbe\u7f6e800<\/p>\n<p>upstream httpds {<br \/>\n    server 127.0.0.1:8050    weight&#061;5  max_conns&#061;800;<br \/>\n    server 127.0.0.1:8060    weight&#061;1;<br \/>\n} <\/p>\n<h5 id=\"max_fails%E3%80%81%20fail_timeout\">max_fails\u3001 fail_timeout<\/h5>\n<p>max_fails:\u5931\u8d25\u591a\u5c11\u6b21 \u8ba4\u4e3a\u4e3b\u673a\u5df2\u6302\u6389\u5219&#xff0c;\u8e22\u51fa&#xff0c;\u516c\u53f8\u8d44\u6e90\u5c11\u7684\u8bdd\u4e00\u822c\u8bbe\u7f6e2~3\u6b21&#xff0c;\u591a\u7684\u8bdd\u8bbe\u7f6e1\u6b21<\/p>\n<p>max_fails&#061;3 fail_timeout&#061;30s\u4ee3\u8868\u572830\u79d2\u5185\u8bf7\u6c42\u67d0\u4e00\u5e94\u7528\u5931\u8d253\u6b21&#xff0c;\u8ba4\u4e3a\u8be5\u5e94\u7528\u5b95\u673a&#xff0c;\u540e\u7b49\u5f8530\u79d2&#xff0c;\u8fd9\u671f\u95f4\u5185\u4e0d\u4f1a\u518d\u628a\u65b0\u8bf7\u6c42\u53d1\u9001\u5230\u5b95\u673a\u5e94\u7528&#xff0c;\u800c\u662f\u76f4\u63a5\u53d1\u5230\u6b63\u5e38\u7684\u90a3\u4e00\u53f0&#xff0c;\u65f6\u95f4\u5230\u540e\u518d\u6709\u8bf7\u6c42\u8fdb\u6765\u7ee7\u7eed\u5c1d\u8bd5\u8fde\u63a5\u5b95\u673a\u5e94\u7528\u4e14\u4ec5\u5c1d\u8bd51\u6b21&#xff0c;\u5982\u679c\u8fd8\u662f\u5931\u8d25&#xff0c;\u5219\u7ee7\u7eed\u7b49\u5f8530\u79d2&#8230;\u4ee5\u6b64\u5faa\u73af&#xff0c;\u76f4\u5230\u6062\u590d\u3002<\/p>\n<p>upstream httpds {<br \/>\n    server 127.0.0.1:8050    weight&#061;1  max_fails&#061;1  fail_timeout&#061;20;<br \/>\n    server 127.0.0.1:8060    weight&#061;1;<br \/>\n} <\/p>\n<h5 id=\"%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1%E7%AE%97%E6%B3%95\">\u8d1f\u8f7d\u5747\u8861\u7b97\u6cd5<\/h5>\n<p>\u8f6e\u8be2&#043;weight ip_hash url_hash least_conn least_time<\/p>\n<h4 id=\"%E5%81%A5%E5%BA%B7%E6%A3%80%E6%9F%A5%E6%A8%A1%E5%9D%97\">\u5065\u5eb7\u68c0\u67e5\u6a21\u5757<\/h4>\n<p>\u914d\u7f6e\u4e00\u4e2astatus\u7684location<\/p>\n<p>location \/status {<br \/>\n            check_status;<br \/>\n\u00a0<br \/>\n        }<\/p>\n<p>\u5728upstream\u914d\u7f6e\u5982\u4e0b<\/p>\n<p>check interval&#061;3000 rise&#061;2 fall&#061;5 timeout&#061;1000 type&#061;http;<br \/>\ncheck_http_send &#034;HEAD \/ HTTP\/1.0\\\\r\\\\n\\\\r\\\\n&#034;;<br \/>\ncheck_http_expect_alive http_2xx http_3xx;<\/p>\n<h3 id=\"session%E5%85%B1%E4%BA%AB\">session\u5171\u4eab<\/h3>\n<h4 id=\"Memcached\">Memcached<\/h4>\n<h5 id=\"%E5%AE%89%E8%A3%85\">\u5b89\u88c5<\/h5>\n<ul>\n<li>\n<p>\u5b89\u88c5libevent<\/p>\n<\/li>\n<li>\n<p>\u5b89\u88c5memcached<\/p>\n<\/li>\n<\/ul>\n<p>\u53ef\u4ee5\u7528yum\u65b9\u5f0f\u5b89\u88c5 yum \u2013y install memcached<\/p>\n<h5 id=\"%E5%90%AF%E5%8A%A8memcached\">\u542f\u52a8memcached<\/h5>\n<p>memcached -d -m 128 -u root -l 192.168.43.151 -p 11210 -c 256 -P \/tmp\/memcached.pid<br \/>\nmemcached-tool 192.168.2.11:11211<br \/>\n\u53c2\u6570\u89e3\u91ca&#xff1a;<br \/>\n-d:\u540e\u53f0\u542f\u52a8\u670d\u52a1<br \/>\n-m:\u7f13\u5b58\u5927\u5c0f<br \/>\n-p&#xff1a;\u7aef\u53e3<br \/>\n-l:IP<br \/>\n-P:\u670d\u52a1\u5668\u542f\u52a8\u540e\u7684\u7cfb\u7edf\u8fdb\u7a0bID&#xff0c;\u5b58\u50a8\u7684\u6587\u4ef6<br \/>\n-u:\u670d\u52a1\u5668\u542f\u52a8\u662f\u4ee5\u54ea\u4e2a\u7528\u6237\u540d\u4f5c\u4e3a\u7ba1\u7406\u7528\u6237 <\/p>\n<h5 id=\"Nginx%E9%85%8D%E7%BD%AE\">Nginx\u914d\u7f6e<\/h5>\n<p>upstream tomcat{<br \/>\n        server 192.168.1.52:8080;<br \/>\n        server 192.168.1.53:8080;<br \/>\n      }<\/p>\n<p>        location \/tomcat {<br \/>\n        proxy_pass http:\/\/tomcat\/;<\/p>\n<h4 id=\"Tomcat%E9%85%8D%E7%BD%AE\">Tomcat\u914d\u7f6e<\/h4>\n<p>\u5230tomcat\u7684lib\u4e0b&#xff0c;jar\u5305\u89c1\u9644\u4ef6<\/p>\n<p>\u6bcf\u4e2atomcat\u91cc\u9762\u7684context.xml\u4e2d\u52a0\u5165<\/p>\n<\/p>\n<p>&lt;Manager className&#061;&#034;de.javakaffee.web.msm.MemcachedBackupSessionManager&#034;<br \/>\nmemcachedNodes&#061;&#034;n1:192.168.50.151:11211&#034;<br \/>\n    sticky&#061;&#034;false&#034;<br \/>\n    lockingMode&#061;&#034;auto&#034;<br \/>\n    sessionBackupAsync&#061;&#034;false&#034;<br \/>\nrequestUriIgnorePattern&#061;&#034;.*\\\\.(ico|png|gif|jpg|css|js)$&#034;<br \/>\n    sessionBackupTimeout&#061;&#034;1000&#034; transcoderFactoryClass&#061;&#034;de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory&#034;<br \/>\n\/&gt; <\/p>\n<h4 id=\"http_proxy%20%E6%9C%AC%E5%9C%B0%E7%A3%81%E7%9B%98%E7%BC%93%E5%AD%98\">http_proxy \u672c\u5730\u78c1\u76d8\u7f13\u5b58<\/h4>\n<p>proxy_cache_path \/path\/to\/cache levels&#061;1:2 keys_zone&#061;my_cache:10m max_size&#061;10g inactive&#061;60m use_temp_path&#061;off;<br \/>\nserver {<br \/>\n\u2002\u2002\u2002\u2002 set $upstream http:\/\/ip:port<br \/>\n\u2002\u2002\u2002\u2002 \u2002\u2002\u2002\u2002 location \/ {<br \/>\n\u2002\u2002\u2002\u2002 \u2002\u2002\u2002\u2002\u2002\u2002\u2002\u2002 \u2002\u2002\u2002\u2002 proxy_cache my_cache;<br \/>\n\u2002\u2002\u2002\u2002 \u2002\u2002\u2002\u2002\u2002\u2002\u2002\u2002 \u2002\u2002\u2002\u2002 proxy_pass $upstream;<br \/>\n                }<br \/>\n}<\/p>\n<p>\uf06c\/path\/to\/cache  #\u672c\u5730\u8def\u5f84&#xff0c;\u7528\u6765\u8bbe\u7f6eNginx\u7f13\u5b58\u8d44\u6e90\u7684\u5b58\u653e\u5730\u5740<br \/>\n\uf06clevels          #\u9ed8\u8ba4\u6240\u6709\u7f13\u5b58\u6587\u4ef6\u90fd\u653e\u5728\u540c\u4e00\u4e2a\/path\/to\/cache\u4e0b&#xff0c;\u4f46\u662f\u4f1a\u5f71\u54cd\u7f13\u5b58\u7684\u6027\u80fd&#xff0c;\u56e0\u6b64\u901a\u5e38\u4f1a\u5728\/path\/to\/cache\u4e0b\u9762\u5efa\u7acb\u5b50\u76ee\u5f55\u7528\u6765\u5206\u522b\u5b58\u653e\u4e0d\u540c\u7684\u6587\u4ef6\u3002\u5047\u8bbelevels&#061;1:2&#xff0c;Nginx\u4e3a\u5c06\u8981\u7f13\u5b58\u7684\u8d44\u6e90\u751f\u6210\u7684key\u4e3af4cd0fbc769e94925ec5540b6a4136d0&#xff0c;\u90a3\u4e48key\u7684\u6700\u540e\u4e00\u4f4d0&#xff0c;\u4ee5\u53ca\u5012\u6570\u7b2c2-3\u4f4d6d\u4f5c\u4e3a\u4e24\u7ea7\u7684\u5b50\u76ee\u5f55&#xff0c;\u4e5f\u5c31\u662f\u8be5\u8d44\u6e90\u6700\u7ec8\u4f1a\u88ab\u7f13\u5b58\u5230\/path\/to\/cache\/0\/6d\u76ee\u5f55\u4e2d<br \/>\n\uf06ckey_zone        #\u5728\u5171\u4eab\u5185\u5b58\u4e2d\u8bbe\u7f6e\u4e00\u5757\u5b58\u50a8\u533a\u57df\u6765\u5b58\u653e\u7f13\u5b58\u7684key\u548cmetadata&#xff08;\u7c7b\u4f3c\u4f7f\u7528\u6b21\u6570&#xff09;&#xff0c;\u8fd9\u6837nginx\u53ef\u4ee5\u5feb\u901f\u5224\u65ad\u4e00\u4e2arequest\u662f\u5426\u547d\u4e2d\u6216\u8005\u672a\u547d\u4e2d\u7f13\u5b58&#xff0c;1m\u53ef\u4ee5\u5b58\u50a88000\u4e2akey&#xff0c;10m\u53ef\u4ee5\u5b58\u50a880000\u4e2akey<br \/>\n\uf06cmax_size        #\u6700\u5927cache\u7a7a\u95f4&#xff0c;\u5982\u679c\u4e0d\u6307\u5b9a&#xff0c;\u4f1a\u4f7f\u7528\u6389\u6240\u6709disk space&#xff0c;\u5f53\u8fbe\u5230\u914d\u989d\u540e&#xff0c;\u4f1a\u5220\u9664\u6700\u5c11\u4f7f\u7528\u7684cache\u6587\u4ef6<br \/>\n\uf06cinactive        #\u672a\u88ab\u8bbf\u95ee\u6587\u4ef6\u5728\u7f13\u5b58\u4e2d\u4fdd\u7559\u65f6\u95f4&#xff0c;\u672c\u914d\u7f6e\u4e2d\u5982\u679c60\u5206\u949f\u672a\u88ab\u8bbf\u95ee\u5219\u4e0d\u8bba\u72b6\u6001\u662f\u5426\u4e3aexpired&#xff0c;\u7f13\u5b58\u63a7\u5236\u7a0b\u5e8f\u4f1a\u5220\u6389\u6587\u4ef6\u3002inactive\u9ed8\u8ba4\u662f10\u5206\u949f\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f&#xff0c;inactive\u548cexpired\u914d\u7f6e\u9879\u7684\u542b\u4e49\u662f\u4e0d\u540c\u7684&#xff0c;expired\u53ea\u662f\u7f13\u5b58\u8fc7\u671f&#xff0c;\u4f46\u4e0d\u4f1a\u88ab\u5220\u9664&#xff0c;inactive\u662f\u5220\u9664\u6307\u5b9a\u65f6\u95f4\u5185\u672a\u88ab\u8bbf\u95ee\u7684\u7f13\u5b58\u6587\u4ef6<br \/>\n\uf06cuse_temp_path   #\u5982\u679c\u4e3aoff&#xff0c;\u5219nginx\u4f1a\u5c06\u7f13\u5b58\u6587\u4ef6\u76f4\u63a5\u5199\u5165\u6307\u5b9a\u7684cache\u6587\u4ef6\u4e2d&#xff0c;\u800c\u4e0d\u662f\u4f7f\u7528temp_path\u5b58\u50a8&#xff0c;official\u5efa\u8bae\u4e3aoff&#xff0c;\u907f\u514d\u6587\u4ef6\u5728\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u4e0d\u5fc5\u8981\u7684\u62f7\u8d1d<br \/>\n\uf06cproxy_cache     #\u542f\u7528proxy cache&#xff0c;\u5e76\u6307\u5b9akey_zone\u3002\u53e6\u5916&#xff0c;\u5982\u679cproxy_cache off\u8868\u793a\u5173\u95ed\u6389\u7f13\u5b58\u3002 <\/p>\n<h2 id=\"%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8\">\u5f00\u673a\u542f\u52a8<\/h2>\n<p>chkconfig &#8211;list<br \/>\nchkconfig &#8211;add nginx<br \/>\nchkconfig nginx on <\/p>\n<h2 id=\"%E8%99%9A%E6%8B%9F%E7%9B%AE%E5%BD%95\">\u865a\u62df\u76ee\u5f55<\/h2>\n<p>   location \/d{<br \/>\n        alias  \/var\/data\/d1;<br \/>\n        index  index.html index.htm a.html;<br \/>\n    } <\/p>\n<h2 id=\"%E8%87%AA%E5%8A%A8%E7%B4%A2%E5%BC%95\">\u81ea\u52a8\u7d22\u5f15<\/h2>\n<p> location \/art {<br \/>\n        alias  \/var\/data\/d1\/;<br \/>\n          autoindex on;<\/p>\n<p>    } <\/p>\n<h2 id=\"%E5%8A%A8%E9%9D%99%E5%88%86%E7%A6%BB\">\u52a8\u9759\u5206\u79bb<\/h2>\n<p>   location \/ {<br \/>\nproxy_pass http:\/\/192.168.0.11:803;<\/p>\n<p>        }<\/p>\n<p>     location ~ .*\\\\.(gif|jpg|jpeg|png|bmp|swf|html|htm|css|js)$ {<br \/>\n            root  \/var\/data\/d1\/;<\/p>\n<p>        } <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e15\u6b21\uff0c\u6536\u85cf28\u6b21\u3002user a a;_server tengine<\/p>\n","protected":false},"author":2,"featured_media":15685,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[87,43,44],"topic":[],"class_list":["post-15687","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-87","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Tengine\uff1a\u9ad8\u6027\u80fdWeb \u670d\u52a1\u5668\u4e0e\u53cd\u5411\u4ee3\u7406 - \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\/15687.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tengine\uff1a\u9ad8\u6027\u80fdWeb \u670d\u52a1\u5668\u4e0e\u53cd\u5411\u4ee3\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e15\u6b21\uff0c\u6536\u85cf28\u6b21\u3002user a a;_server tengine\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/15687.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T14:13:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418141301-68025dede1fbe.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=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/15687.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/15687.html\",\"name\":\"Tengine\uff1a\u9ad8\u6027\u80fdWeb \u670d\u52a1\u5668\u4e0e\u53cd\u5411\u4ee3\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T14:13:03+00:00\",\"dateModified\":\"2025-04-18T14:13:03+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/15687.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/15687.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/15687.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tengine\uff1a\u9ad8\u6027\u80fdWeb \u670d\u52a1\u5668\u4e0e\u53cd\u5411\u4ee3\u7406\"}]},{\"@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":"Tengine\uff1a\u9ad8\u6027\u80fdWeb \u670d\u52a1\u5668\u4e0e\u53cd\u5411\u4ee3\u7406 - \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\/15687.html","og_locale":"zh_CN","og_type":"article","og_title":"Tengine\uff1a\u9ad8\u6027\u80fdWeb \u670d\u52a1\u5668\u4e0e\u53cd\u5411\u4ee3\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e15\u6b21\uff0c\u6536\u85cf28\u6b21\u3002user a a;_server tengine","og_url":"https:\/\/www.wsisp.com\/helps\/15687.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T14:13:03+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418141301-68025dede1fbe.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/15687.html","url":"https:\/\/www.wsisp.com\/helps\/15687.html","name":"Tengine\uff1a\u9ad8\u6027\u80fdWeb \u670d\u52a1\u5668\u4e0e\u53cd\u5411\u4ee3\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T14:13:03+00:00","dateModified":"2025-04-18T14:13:03+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/15687.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/15687.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/15687.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Tengine\uff1a\u9ad8\u6027\u80fdWeb \u670d\u52a1\u5668\u4e0e\u53cd\u5411\u4ee3\u7406"}]},{"@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\/15687","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=15687"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/15687\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/15685"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=15687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=15687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=15687"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=15687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}