{"id":18061,"date":"2024-11-18T08:23:50","date_gmt":"2024-11-18T00:23:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18061\/"},"modified":"2024-11-18T08:23:50","modified_gmt":"2024-11-18T00:23:50","slug":"nginx%e5%ae%95%e6%9c%ba%e6%80%8e%e4%b9%88%e5%8a%9e","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18061\/","title":{"rendered":"nginx\u5b95\u673a\u600e\u4e48\u529e"},"content":{"rendered":"<blockquote><p>\n  nginx \u6545\u969c\u6392\u9664\u6b65\u9aa4\uff1a\u68c0\u67e5 nginx \u72b6\u6001\u548c\u9519\u8bef\u65e5\u5fd7\u91cd\u542f nginx\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u8bed\u6cd5\u9519\u8bef\u548c\u65e0\u6548\u8bbe\u7f6e\u68c0\u67e5\u6587\u4ef6\u63cf\u8ff0\u7b26\u548c\u5185\u5b58\u4f7f\u7528\u9650\u5236\u68c0\u67e5\u5b89\u5168\u7ec4\u548c\u9632\u706b\u5899\u89c4\u5219\u67e5\u770b nginx \u8fdb\u7a0b\u662f\u5426\u6302\u8d77\u68c0\u67e5\u6587\u4ef6\u7cfb\u7edf\u53ef\u7528\u7a7a\u95f4\u68c0\u67e5\u7b2c\u4e09\u65b9\u6a21\u5757\u7684\u5b89\u88c5\u548c\u7a33\u5b9a\u6027\u6392\u9664\u786c\u4ef6\u95ee\u9898\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/27\/2024052721181984490.jpg\" class=\"aligncenter\" title=\"nginx\u5b95\u673a\u600e\u4e48\u529e\u63d2\u56fe\" alt=\"nginx\u5b95\u673a\u600e\u4e48\u529e\u63d2\u56fe\" \/><\/p>\n<p><strong> \u5b95\u673a\u6545\u969c\u6392\u9664<\/strong><\/p>\n<p><strong>1. \u786e\u5b9a\u95ee\u9898<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 systemctl status nginx \u68c0\u67e5 nginx \u7684\u72b6\u6001\u3002<\/li>\n<li>\u67e5\u770b \/var\/log\/nginx\/error.log \u4e2d\u7684\u9519\u8bef\u6d88\u606f\u3002<\/li>\n<\/ul>\n<p><strong>2. \u91cd\u542f nginx<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 systemctl restart nginx \u5c1d\u8bd5\u91cd\u542f nginx\u3002<\/li>\n<li>\u5982\u679c\u91cd\u542f\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528 journalctl -xe \u68c0\u67e5\u8be6\u7ec6\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<p><strong>3. \u68c0\u67e5\u914d\u7f6e\u95ee\u9898<\/strong><\/p>\n<ul>\n<li>\u67e5\u770b \/etc\/nginx\/nginx.conf \u4e2d\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u786e\u4fdd\u6ca1\u6709\u8bed\u6cd5\u9519\u8bef\u6216\u65e0\u6548\u8bbe\u7f6e\u3002<\/li>\n<li>\u7279\u522b\u6ce8\u610f server\u3001listen \u548c root \u6307\u4ee4\u3002<\/li>\n<\/ul>\n<p><strong>4. \u68c0\u67e5\u8d44\u6e90\u9650\u5236<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 ulimit -n \u68c0\u67e5\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u9650\u5236\u3002nginx \u9ed8\u8ba4\u9700\u8981 1024 \u4e2a\u3002<\/li>\n<li>\u4f7f\u7528 free -m \u68c0\u67e5\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002<\/li>\n<\/ul>\n<p><strong>5. \u68c0\u67e5\u5b89\u5168\u7ec4<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd nginx \u7684\u5b89\u5168\u7ec4\u5141\u8bb8\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u4f20\u5165\u8fde\u63a5\u3002<\/li>\n<li>\u68c0\u67e5\u9632\u706b\u5899\u89c4\u5219\u662f\u5426\u6ca1\u6709\u963b\u6b62 nginx\u3002<\/li>\n<\/ul>\n<p><strong>6. \u68c0\u67e5\u8fdb\u7a0b\u6302\u8d77<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 ps auxf | grep nginx \u68c0\u67e5 nginx \u8fdb\u7a0b\u662f\u5426\u6302\u8d77\u3002<\/li>\n<li>\u5982\u679c\u8fdb\u7a0b\u6302\u8d77\uff0c\u8bf7\u4f7f\u7528 gstack \u83b7\u53d6\u5806\u6808\u8ddf\u8e2a\u3002 <\/li>\n<\/ul>\n<p><strong>7. \u68c0\u67e5\u6587\u4ef6\u7cfb\u7edf\u6545\u969c<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 df -h \u68c0\u67e5 nginx \u65e5\u5fd7\u548c\u914d\u7f6e\u76ee\u5f55\u7684\u53ef\u7528\u7a7a\u95f4\u3002<\/li>\n<li>\u5982\u679c\u7a7a\u95f4\u4e0d\u8db3\uff0c\u8bf7\u8003\u8651\u6e05\u9664\u65e7\u65e5\u5fd7\u6216\u5347\u7ea7\u5230\u66f4\u5927\u5bb9\u91cf\u7684\u6587\u4ef6\u7cfb\u7edf\u3002<\/li>\n<\/ul>\n<p><strong>8. \u68c0\u67e5\u7b2c\u4e09\u65b9\u6a21\u5757<\/strong><\/p>\n<ul>\n<li>\u5982\u679c nginx \u4f7f\u7528\u7b2c\u4e09\u65b9\u6a21\u5757\uff0c\u8bf7\u786e\u4fdd\u5b83\u4eec\u5b89\u88c5\u6b63\u786e\u3002<\/li>\n<li>\u7981\u7528\u53ef\u7591\u6a21\u5757\u6216\u56de\u9000\u5230\u7a33\u5b9a\u7248\u672c\u3002<\/li>\n<\/ul>\n<p><strong>9. \u68c0\u67e5\u786c\u4ef6\u95ee\u9898<\/strong><\/p>\n<ul>\n<li>\u5982\u679c\u6392\u9664\u4e86\u6240\u6709\u8f6f\u4ef6\u95ee\u9898\uff0c\u8bf7\u68c0\u67e5\u670d\u52a1\u5668\u786c\u4ef6\u662f\u5426\u6709\u6545\u969c\u3002<\/li>\n<li>\u91cd\u542f\u670d\u52a1\u5668\u6216\u8054\u7cfb\u7cfb\u7edf\u7ba1\u7406\u5458\u5bfb\u6c42\u5e2e\u52a9\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5b95\u673a\u600e\u4e48\u529e\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>nginx \u6545\u969c\u6392\u9664\u6b65\u9aa4\uff1a\u68c0\u67e5 nginx \u72b6\u6001\u548c\u9519\u8bef\u65e5\u5fd7\u91cd\u542f nginx\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u8bed\u6cd5\u9519\u8bef\u548c\u65e0\u6548\u8bbe\u7f6e\u68c0\u67e5\u6587\u4ef6\u63cf\u8ff0\u7b26\u548c\u5185\u5b58\u4f7f\u7528\u9650\u5236\u68c0\u67e5\u5b89\u5168\u7ec4\u548c\u9632\u706b\u5899\u89c4\u5219\u67e5\u770b nginx \u8fdb\u7a0b\u662f\u5426\u6302\u8d77\u68c0\u67e5\u6587\u4ef6\u7cfb\u7edf\u53ef\u7528\u7a7a\u95f4\u68c0\u67e5\u7b2c\u4e09\u65b9\u6a21\u5757\u7684\u5b89\u88c5\u548c\u7a33\u5b9a\u6027\u6392\u9664\u786c\u4ef6\u95ee\u9898 \u5b95\u673a\u6545\u969c\u6392\u9664 1. \u786e\u5b9a\u95ee\u9898 \u4f7f\u7528 systemctl status nginx \u68c0\u67e5 nginx \u7684\u72b6\u6001\u3002 \u67e5\u770b \/var\/log\/nginx\/error.log \u4e2d\u7684\u9519\u8bef\u6d88\u606f\u3002 2. \u91cd\u542f nginx \u4f7f\u7528 systemctl restart nginx \u5c1d\u8bd5\u91cd\u542f nginx\u3002 \u5982\u679c\u91cd\u542f\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528 journalctl -xe \u68c0\u67e5\u8be6\u7ec6\u4fe1\u606f\u3002 3. \u68c0\u67e5\u914d\u7f6e\u95ee\u9898 \u67e5\u770b \/etc\/nginx\/nginx.conf \u4e2d\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u786e\u4fdd\u6ca1\u6709\u8bed\u6cd5\u9519\u8bef\u6216\u65e0\u6548\u8bbe\u7f6e\u3002 \u7279\u522b\u6ce8\u610f server\u3001listen \u548c root \u6307\u4ee4\u3002 4. \u68c0\u67e5\u8d44\u6e90\u9650\u5236 \u4f7f\u7528 ulimit -n \u68c0\u67e5\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u9650\u5236\u3002nginx \u9ed8\u8ba4\u9700\u8981 1024 \u4e2a\u3002 \u4f7f\u7528 free -m [&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-18061","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18061","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=18061"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18061\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}