{"id":139203,"date":"2019-03-16T09:31:23","date_gmt":"2019-03-16T01:31:23","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=139203"},"modified":"2019-03-08T09:32:32","modified_gmt":"2019-03-08T01:32:32","slug":"nginx-status-reload","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/nginx-status-reload.html","title":{"rendered":"\u5c0f\u767d\u5165\u95e8\u4f7f\u7528Nginx\u57fa\u7840\u7684\u5e38\u7528\u64cd\u4f5c"},"content":{"rendered":"
nginx\u542f\u52a8\uff0c\u91cd\u542f\uff0c\u5173\u95ed\u547d\u4ee4<\/strong><\/div>\n
\u505c\u6b62\u64cd\u4f5c<\/strong><\/span><\/div>\n

\u505c\u6b62\u64cd\u4f5c\u524d\u9700\u8981ps\u5f53\u524dNginx\u7684\u6240\u6709\u8fdb\u7a0b<\/p>\n

\u6b65\u9aa41\uff1a\u67e5\u8be2nginx\u4e3b\u8fdb\u7a0b\u53f7<\/p>\n

ps -ef | grep nginx<\/pre>\n

\u5728\u8fdb\u7a0b\u5217\u8868\u91cc \u9762\u627emaster\u8fdb\u7a0b\uff0c\u5b83\u7684\u7f16\u53f7\u5c31\u662f\u4e3b\u8fdb\u7a0b\u53f7\u4e86<\/p>\n

\u6b65\u9aa42\uff1a\u53d1\u9001\u4fe1\u53f7, \u4ece\u5bb9\u505c\u6b62Nginx\uff1a<\/p>\n

kill -QUIT \u4e3b\u8fdb\u7a0b\u53f7<\/pre>\n
\u5feb\u901f\u505c\u6b62Nginx\uff1a<\/strong><\/span><\/div>\n
kill -TERM \u4e3b\u8fdb\u7a0b\u53f7<\/pre>\n
\u5f3a\u5236\u505c\u6b62Nginx\uff1a<\/strong><\/span><\/div>\n
pkill -9 nginx<\/pre>\n

\u53e6\u5916\uff0c \u82e5\u5728nginx.conf\u914d\u7f6e\u4e86pid\u6587\u4ef6\u5b58\u653e\u8def\u5f84\u5219\u8be5\u6587\u4ef6\u5b58\u653e\u7684\u5c31\u662fNginx\u4e3b\u8fdb\u7a0b\u53f7\uff0c\u5982\u679c\u6ca1\u6307\u5b9a\u5219\u653e\u5728nginx\u7684logs\u76ee\u5f55\u4e0b\u3002\u6709\u4e86pid\u6587 \u4ef6\uff0c\u6211\u4eec\u5c31\u4e0d\u7528\u5148\u67e5\u8be2Nginx\u7684\u4e3b\u8fdb\u7a0b\u53f7\uff0c\u800c\u76f4\u63a5\u5411Nginx\u53d1\u9001\u4fe1\u53f7\u4e86\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n

kill -\u4fe1\u53f7\u7c7b\u578b '\/usr\/nginx\/logs\/nginx.pid'<\/pre>\n
\u5e73\u6ed1\u91cd\u542f<\/strong><\/div>\n

\u5982\u679c\u66f4\u6539\u4e86\u914d\u7f6e\u5c31\u8981\u91cd\u542fNginx\uff0c\u8981\u5148\u5173\u95edNginx\u518d\u6253\u5f00\uff1f\u4e0d\u662f\u7684\uff0c\u53ef\u4ee5\u5411Nginx \u53d1\u9001\u4fe1\u53f7\uff0c\u5e73\u6ed1\u91cd\u542f\u3002<\/p>\n

\u5e73\u6ed1\u91cd\u542f\u547d\u4ee4\uff1a<\/strong><\/span><\/div>\n
kill -HUP \u4f4f\u8fdb\u79f0\u53f7\u6216\u8fdb\u7a0b\u53f7\u6587\u4ef6\u8def\u5f84<\/pre>\n

\u6216\u8005\u4f7f\u7528\uff1a<\/p>\n

\/usr\/nginx\/sbin\/nginx -s reload<\/pre>\n

\u6ce8\u610f\uff0c\u4fee\u6539\u4e86\u914d\u7f6e\u6587\u4ef6\u540e\u6700\u597d\u5148\u68c0\u67e5\u4e00\u4e0b\u4fee\u6539\u8fc7\u7684\u914d\u7f6e\u6587\u4ef6\u662f\u5426\u6b63 \u786e\uff0c\u4ee5\u514d\u91cd\u542f\u540eNginx\u51fa\u73b0\u9519\u8bef\u5f71\u54cd\u670d\u52a1\u5668\u7a33\u5b9a\u8fd0\u884c\u3002<\/p>\n

\u5224\u65adNginx\u914d\u7f6e\u662f\u5426\u6b63\u786e\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n

nginx -t -c \/usr\/nginx\/conf\/nginx.conf<\/pre>\n

\u6216\u8005<\/p>\n

\/usr\/nginx\/sbin\/nginx -t\r\n<\/pre>\n
\u5e73\u6ed1\u5347\u7ea7<\/strong><\/div>\n

\u5982\u679c\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u7684Nginx\u8981\u8fdb\u884c\u5347\u7ea7\u3001\u6dfb\u52a0\u6216\u5220\u9664\u6a21\u5757\u65f6\uff0c\u6211\u4eec\u9700 \u8981\u505c\u6389\u670d\u52a1\u5668\u5e76\u505a\u76f8\u5e94\u4fee\u6539\uff0c\u8fd9\u6837\u670d\u52a1\u5668\u5c31\u8981\u5728\u4e00\u6bb5\u65f6\u95f4\u5185\u505c\u6b62\u670d\u52a1\uff0cNginx\u53ef\u4ee5\u5728\u4e0d\u505c\u673a\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u5404\u79cd\u5347\u7ea7\u52a8\u4f5c\u800c\u4e0d\u5f71\u54cd\u670d\u52a1\u5668\u8fd0\u884c\u3002<\/p>\n

\u6b65\u9aa41\uff1a \u5982\u679c\u5347\u7ea7Nginx\u7a0b\u5e8f\uff0c\u5148\u7528\u65b0\u7a0b\u5e8f\u66ff\u6362\u65e7\u7a0b\u5e8f\u6587\u4ef6\uff0c\u7f16\u8bd1\u5b89\u88c5\u7684\u8bdd\u65b0\u7a0b\u5e8f\u76f4\u63a5\u7f16\u8bd1\u5230Nginx\u5b89\u88c5\u76ee\u5f55\u4e2d\u3002<\/p>\n

\u6b65\u9aa42\uff1a\u6267\u884c\u547d\u4ee4<\/p>\n

kill -USR2 \u65e7\u7248\u7a0b\u5e8f\u7684\u4e3b\u8fdb\u7a0b\u53f7\u6216\u8fdb\u7a0b\u6587\u4ef6\u540d<\/pre>\n

\u6b64\u65f6\u65e7\u7684Nginx\u4e3b\u8fdb\u7a0b\u5c06\u4f1a\u628a\u81ea\u5df1\u7684\u8fdb\u7a0b\u6587\u4ef6\u6539\u540d\u4e3a.oldbin\uff0c\u7136\u540e\u6267\u884c\u65b0\u7248 Nginx\u3002\u65b0\u65e7Nginx\u4f1a\u540c\u5e02\u8fd0\u884c\uff0c\u5171\u540c\u5904\u7406\u8bf7\u6c42\u3002<\/p>\n

\u8fd9\u65f6\u8981\u9010\u6b65\u505c\u6b62\u65e7\u7248 Nginx\uff0c\u8f93\u5165\u547d\u4ee4\uff1a<\/p>\n

kill -WINCH \u65e7\u7248\u4e3b\u8fdb\u7a0b\u53f7<\/pre>\n

\u6162\u6162\u65e7\u7684\u5de5\u4f5c\u8fdb\u7a0b\u5c31\u90fd\u4f1a\u968f\u7740\u4efb\u52a1\u6267\u884c\u5b8c\u6bd5\u800c\u9000\u51fa\uff0c\u65b0\u7248\u7684Nginx\u7684\u5de5\u4f5c\u8fdb\u7a0b\u4f1a\u9010\u6e10\u53d6\u4ee3\u65e7\u7248 \u5de5\u4f5c\u8fdb\u7a0b\uff0c\u6b64\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u51b3\u5b9a\u4f7f\u7528\u65b0\u7248\u8fd8\u662f\u6062\u590d\u5230\u65e7\u7248\u3002<\/p>\n

\u4e0d\u91cd\u8f7d\u914d\u7f6e\u542f\u52a8\u65b0\/\u65e7\u5de5\u4f5c\u8fdb\u7a0b<\/strong><\/span><\/div>\n
kill -HUP \u65e7\/\u65b0\u7248\u4e3b\u8fdb\u7a0b\u53f7<\/pre>\n
\u4ece\u5bb9\u5173\u95ed\u65e7\/\u65b0\u8fdb\u7a0b<\/strong><\/span><\/div>\n
kill -QUIT \u65e7\/\u65b0\u4e3b\u8fdb\u7a0b\u53f7<\/pre>\n

\u5982\u679c\u6b64\u65f6\u62a5\u9519\uff0c\u63d0\u793a\u8fd8\u6709\u8fdb\u7a0b\u6ca1\u6709\u7ed3\u675f\u5c31\u7528\u4e0b\u9762\u547d\u4ee4\u5148\u5173\u95ed\u65e7\/\u65b0\u5de5\u4f5c\u8fdb\u7a0b\uff0c\u518d\u5173\u95ed\u4e3b\u8fdb\u7a0b\u53f7\uff1a<\/p>\n

\u5173\u95ed\u4e3b\u8fdb\u7a0b\u53f7<\/strong><\/span><\/div>\n
kill -TERM \u65e7\/\u65b0\u5de5\u4f5c\u8fdb\u7a0b\u53f7<\/pre>\n

\u8fd9\u6837\u4e0b\u6765\uff0c\u5982\u679c\u8981\u6062\u590d\u5230\u65e7\u7248\u672c\uff0c\u53ea\u9700\u8981\u4e0a\u9762\u7684\u51e0\u4e2a\u6b65\u9aa4\u90fd\u662f\u64cd\u4f5c\u65b0\u7248\u4e3b\u8fdb\u7a0b\u53f7\uff0c\u5982\u679c\u8981\u7528\u65b0\u7248\u672c\u5c31\u4e0a\u9762\u7684\u51e0\u4e2a\u6b65\u9aa4\u90fd\u64cd\u4f5c\u65e7\u7248\u4e3b\u8fdb\u7a0b\u53f7\u5c31\u884c\u4e86\u3002<\/p>\n

\u76f8\u5173\u547d\u4ee4<\/strong><\/span><\/div>\n
\r\n\/usr\/local\/nginx-1.0.6\/sbin\/nginx  \/\/\u542f\u52a8nginx\r\n\/usr\/local\/nginx-1.0.6\/sbin\/nginx \u2013t \/\/\u6d4b\u8bd5nginx\u914d\u7f6e\u6587\u4ef6\u7684\u51c6\u786e\u6027\r\n\/usr\/local\/nginx-1.0.6\/sbin\/nginx \u2013s reload \/\/\u91cd\u8f7dnginx\r\n\/usr\/local\/nginx-1.0.6\/sbin\/nginx \u2013s stop \/\/\u5173\u95ednginx\r\n\/usr\/local\/nginx-1.0.6\/sbin\/nginx -V \/\/\u67e5\u770bnginx\u5b89\u88c5\u7684\u6a21\u5757\r\n\/usr\/local\/nginx-1.0.6\/sbin\/nginx -v \/\/\u67e5\u770bnginx\u7684\u7248\u672c\r\n\/usr\/local\/nginx\/sbin\/nginx \u2013s reload \/\/\u91cd\u8f7dnginx\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u505c\u6b62\u64cd\u4f5c\u524d\u9700\u8981ps\u5f53\u524dNginx\u7684\u6240\u6709\u8fdb\u7a0b \u6b65\u9aa41\uff1a\u67e5\u8be2nginx\u4e3b\u8fdb\u7a0b\u53f7 ps -ef | grep ngi […]<\/p>\n","protected":false},"author":668,"featured_media":4896,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-139203","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/139203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=139203"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/139203\/revisions"}],"predecessor-version":[{"id":139269,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/139203\/revisions\/139269"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/4896"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=139203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=139203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=139203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}