{"id":672,"date":"2022-03-03T21:36:50","date_gmt":"2022-03-03T13:36:50","guid":{"rendered":"https:\/\/www.buyao007.icu\/?p=672"},"modified":"2022-03-03T21:36:51","modified_gmt":"2022-03-03T13:36:51","slug":"14-nginx%e7%9a%84%e5%b9%b3%e6%bb%91%e5%8d%87%e7%ba%a7","status":"publish","type":"post","link":"https:\/\/www.buyao007.icu\/?p=672","title":{"rendered":"14.Nginx\u7684\u5e73\u6ed1\u5347\u7ea7"},"content":{"rendered":"\n<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6\u7fa4\u67b6\u6784\u4e0e\u81ea\u52a8\u5316\u8fd0\u7ef4\uff0c\u66fe\u8d1f\u8d23\u56fd\u5185\u67d0\u5927\u578b\u535a\u5ba2\u7f51\u7ad9\u8fd0\u7ef4\u5de5\u4f5c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">1.Nginx\u5e73\u6ed1\u5347\u7ea7\u6982\u8ff0<\/h2>\n\n\n\n<p><strong><em>1.\u4ec0\u4e48\u662f\u5e73\u6ed1\u5347\u7ea7<\/em><\/strong><\/p>\n\n\n\n<p>\u5728\u8fdb\u884c\u670d\u52a1\u7248\u672c\u5347\u7ea7\u7684\u65f6\u5019\uff0c\u5bf9\u4e8e\u7528\u6237\u8bbf\u95ee\u4f53\u9a8c\u65e0\u611f\u77e5\u3001\u4e0d\u4f1a\u9020\u6210\u670d\u52a1\u4e2d\u65ad\u3002<\/p>\n\n\n\n<p><strong><em>2.Nginx\u5e73\u6ed1\u5347\u7ea7\u539f\u7406<\/em><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"273\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/16463137671-1024x273.png\" alt=\"\" class=\"wp-image-673\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/16463137671-1024x273.png 1024w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/16463137671-300x80.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/16463137671-768x205.png 768w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/16463137671.png 1422w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong><em>3.\u5982\u4f55\u5b9e\u73b0Nginx\u5e73\u6ed1\u5347\u7ea7\u601d\u8def\uff08\u5efa\u8bae\u51c6\u5907\u4e00\u4e2a\u5927\u6587\u4ef6\u6301\u7eed\u4e0b\u8f7d\u9a8c\u8bc1\u5347\u7ea7\u662f\u5426\u4f1a\u5f71\u54cd\u4e1a\u52a1\uff09<\/em><\/strong><\/p>\n\n\n\n<p>1.\u4e0b\u8f7d\u65b0\u7248\u672cNginx<br>2.\u4e86\u89e3\u539f\u65e7\u7248\u672cNginx\u7f16\u8bd1\u53c2\u6570<br>3.\u5c06\u65e7\u7684nginx\u4e8c\u8fdb\u5236\u6587\u4ef6\u8fdb\u884c\u5907\u4efd\uff0c\u7136\u540e\u66ff\u6362\u6210\u4e3a\u65b0\u7684 nginx\u4e8c\u8fdb\u5236\u6587\u4ef6<br>4.\u5411\u65e7\u7684Nginx\u7684Master\u8fdb\u7a0b\u53d1\u9001USR2\u4fe1\u53f7<br>          4.1\uff0c\u65e7\u7684master\u8fdb\u7a0b\u7684pid\u6587\u4ef6\u6dfb\u52a0\u540e\u7f00.oldbin<br>          4.2\uff0cmaster\u8fdb\u7a0b\u4f1a\u7528\u65b0nginx\u4e8c\u8fdb\u5236\u6587\u4ef6\u542f\u52a8\u65b0\u7684 master\u8fdb\u7a0b\u3002<br>5.\u5411\u65e7\u7684master\u8fdb\u7a0b\u53d1\u9001WINCH\u4fe1\u53f7\uff0c\u65e7\u7684worker\u5b50\u8fdb \u7a0b\u4f18\u96c5\u9000\u51fa\u3002<br>6.\u5411\u65e7\u7684master\u8fdb\u7a0b\u53d1\u9001QUIT\u4fe1\u53f7\uff0c\u65e7\u7684master\u8fdb\u7a0b\u5c31 \u9000\u51fa\u4e86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">2.Nginx\u5e73\u6ed1\u5347\u7ea7\uff1a1.18 ---> 1.19<\/h2>\n\n\n\n<p><strong><em>1.\u521b\u5efa\u76ee\u5f55\uff0c\u51c6\u5907\u7ad9\u70b9\u6587\u4ef6<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@web01 \/etc\/nginx\/conf.d]# mkdir \/code\r\n&#91;root@web01 \/etc\/nginx\/conf.d]# vim default.conf\r\n&#91;root@web01 \/etc\/nginx\/conf.d]# cat default.conf\r\nserver {\r\n\tlisten 80 default_server;\r\n\tserver_name localhost;\r\n    location \/ {\r\n\tlimit_rate 200k;\r\n\troot \/code;\r\n\tindex index.html index.htm;\r\n\t}\r\n}\r\n\r\n&#91;root@web01 \/etc\/nginx\/conf.d]# nginx -t\r\n&#91;root@web01 ~]# dd if=\/dev\/zero of=\/code\/bigdata bs=500M count=1\r<\/code><\/pre>\n\n\n\n<p><strong><em>2.\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684nginx<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@web01 ~]#  wget http:\/\/nginx.org\/download\/nginx-1.21.1.tar.gz\r\n&#91;root@web01 ~]#  tar xf nginx-1.21.1.tar.gz\r\n&#91;root@web01 ~]#  cd nginx-1.21.1\/\r\n&#91;root@web01 ~\/nginx-1.21.1]#  yum install -y pcre-devel openssl-devel libxml2-devel libxslt-devel gd-devel perl-devel perl-ExtUtils-Embed gperftools\r\n&#91;root@web01 ~\/nginx-1.21.1]#  .\/configure \r\n&#91;root@web01 ~\/nginx-1.21.1]#  make\r<\/code><\/pre>\n\n\n\n<p><strong><em>3.\u5c06\u65e7\u7684nginx\u4e8c\u8fdb\u5236\u6587\u4ef6\u8fdb\u884c\u5907\u4efd\uff0c\u7136\u540e\u66ff\u6362\u6210\u4e3a\u65b0\u7684nginx\u4e8c\u8fdb\u5236\u6587\u4ef6<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@web01 ~]#  mv \/usr\/sbin\/nginx \/usr\/sbin\/nginx_1.20\r\n&#91;root@web01 ~]#  cp \/root\/nginx-1.21.1\/objs\/nginx \/usr\/sbin\/nginx\r\n#\u68c0\u67e5\u662f\u5426\u66ff\u6362\u6210\u529f\r\n&#91;root@web01 ~]#  nginx -v\r\n#\u6253\u5f00\u6d4f\u89c8\u5668\u8f93\u5165\uff1a10.0.0.7\/bigdata\r<\/code><\/pre>\n\n\n\n<p><strong><em>4.\u5411\u65e7\u7684Nginx\u7684Master\u8fdb\u7a0b\u53d1\u9001USR2\u4fe1\u53f7<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>4.1\u3001\u65e7\u7684master\u8fdb\u7a0b\u7684pid\u6587\u4ef6\u6dfb\u52a0\u540e\u7f00.oldbin\r\n4.2\u3001master\u8fdb\u7a0b\u4f1a\u7528\u65b0nginx\u4e8c\u8fdb\u5236\u6587\u4ef6\u542f\u52a8\u65b0\u7684master\u8fdb\u7a0b\u3002\r\n&#91;root@web01 ~]# ps -ef |grep nginx\t\t# 1.18 \r\nroot       1309      1  0 16:53 ?        00:00:00 nginx: master process \/usr\/sbin\/nginx -c \/etc\/nginx\/nginx.conf\r\nwww        1787   1309  0 19:08 ?        00:00:00 nginx: worker process\r\nwww        1788   1309  0 19:08 ?        00:00:00 nginx: worker process\r\nwww        1789   1309  0 19:08 ?        00:00:00 nginx: worker process\r\nwww        1790   1309  0 19:08 ?        00:00:00 nginx: worker process\r\n  \r\n&#91;root@web01 ~]# kill -USR2 1309\t\t\t# \u53d1\u9001USR2\u4fe1\u53f7,\u5e73\u6ed1\u5347\u7ea7Nginx\r\n&#91;root@web01 ~]# ps -ef |grep nginx\r\nroot       1309      1  0 16:53 ?        00:00:00 nginx: master process \/usr\/sbin\/nginx -c \/etc\/nginx\/nginx.conf\r\nwww        1787   1309  0 19:08 ?        00:00:00 nginx: worker process\r\nwww        1788   1309  0 19:08 ?        00:00:00 nginx: worker process\r\nwww        1789   1309  0 19:08 ?        00:00:00 nginx: worker process\r\nwww        1790   1309  0 19:08 ?        00:00:00 nginx: worker process\r\n\r\nroot       5400   1309  0 19:15 ?        00:00:00 nginx: master process \/usr\/sbin\/nginx -c \/etc\/nginx\/nginx.conf\r\nwww        5401   5400  0 19:15 ?        00:00:00 nginx: worker process\r\nwww        5402   5400  0 19:15 ?        00:00:00 nginx: worker process\r\nwww        5403   5400  0 19:15 ?        00:00:00 nginx: worker process\r\nwww        5404   5400  0 19:15 ?        00:00:00 nginx: worker process\r\n\r\n#\u6253\u5f00\u6d4f\u89c8\u5668\u5237\u65b0\u754c\u9762\uff0c\u53d1\u73b0\u4f9d\u65e7\u5728\u4e0b\u8f7d\uff0c\u56e0\u4e3a\u73b0\u5728\u65e7\u7248\u672c\u7684master\u4e0e\u65b0\u7248\u672c\u7684master\u662f\u5171\u5b58\u72b6\u6001\u3002\r\n<\/code><\/pre>\n\n\n\n<p><strong><em>5.\u5411\u65e7\u7684master\u8fdb\u7a0b\u53d1\u9001WINCH\u4fe1\u53f7\uff0c\u65e7\u7684worker\u5b50\u8fdb\u7a0b\u4f18\u96c5\u9000\u51fa\u3002<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@web01 ~]# kill -WINCH 1309\r\n&#91;root@web01 ~]# ps -ef |grep nginx\r\nroot       1309      1  0 16:53 ?        00:00:00 nginx: master process \/usr\/sbin\/nginx -c \/etc\/nginx\/nginx.conf\r\nroot       5400   1309  0 19:15 ?        00:00:00 nginx: master process \/usr\/sbin\/nginx -c \/etc\/nginx\/nginx.conf\r\nwww        5401   5400  0 19:15 ?        00:00:00 nginx: worker process\r\nwww        5402   5400  0 19:15 ?        00:00:00 nginx: worker process\r\nwww        5403   5400  0 19:15 ?        00:00:00 nginx: worker process\r\nwww        5404   5400  0 19:15 ?        00:00:00 nginx: worker process\r<\/code><\/pre>\n\n\n\n<p><strong><em>6.\u5411\u65e7\u7684master\u8fdb\u7a0b\u53d1\u9001QUIT\u4fe1\u53f7\uff0c\u65e7\u7684master\u8fdb\u7a0b\u5c31\u9000\u51fa\u4e86<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@web01 ~]# kill -QUIT 1309\r\n&#91;root@web01 ~]# ps -ef |grep nginx\r\nroot       5400      1  0 19:15 ?        00:00:00 nginx: master process \/usr\/sbin\/nginx -c \/etc\/nginx\/nginx.conf\r\nwww        5401   5400  0 19:15 ?        00:00:00 nginx: worker process\r\nwww        5402   5400  0 19:15 ?        00:00:00 nginx: worker process\r\nwww        5403   5400  0 19:15 ?        00:00:00 nginx: worker process\r\nwww        5404   5400  0 19:15 ?        00:00:00 nginx: worker process\r<\/code><\/pre>\n\n\n\n<p>ps:nginx\u5e73\u6ed1\u964d\u7248\u672c\uff0c\u8ddf\u5347\u7ea7\u64cd\u4f5c\u4e00\u6837\uff0c\u53ea\u662f\u7248\u672c\u4e0d\u4e00\u6837<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":337,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/672"}],"collection":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=672"}],"version-history":[{"count":1,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/672\/revisions"}],"predecessor-version":[{"id":674,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/672\/revisions\/674"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/media\/337"}],"wp:attachment":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}