{"id":56982,"date":"2025-08-15T04:04:46","date_gmt":"2025-08-14T20:04:46","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/56982.html"},"modified":"2025-08-15T04:04:46","modified_gmt":"2025-08-14T20:04:46","slug":"python-wsgi-http-%e6%9c%8d%e5%8a%a1%e5%99%a8-gunicorn%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/56982.html","title":{"rendered":"Python WSGI HTTP \u670d\u52a1\u5668 Gunicorn\u4ecb\u7ecd"},"content":{"rendered":"<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\u4e00\u3001\u4ec0\u4e48\u662f Gunicorn&#xff1f;<\/li>\n<li>\u4e8c\u3001\u4e3a\u4ec0\u4e48\u9700\u8981Gunicorn&#xff1f;<\/li>\n<li>\u4e09\u3001\u5b89\u88c5Gunicorn<\/li>\n<li>\u56db\u3001\u57fa\u672c\u4f7f\u7528<\/li>\n<li>\n<ul>\n<li>\u542f\u52a8\u6700\u7b80\u5355\u7684Gunicorn\u670d\u52a1\u5668<\/li>\n<\/ul>\n<\/li>\n<li>\u4e94\u3001Worker\u7c7b\u578b<\/li>\n<li>\u516d\u3001\u914d\u7f6e\u6587\u4ef6<\/li>\n<li>\u4e03\u3001\u4e0eFlask\u7ed3\u5408\u5b9e\u8df5<\/li>\n<li>\n<ul>\n<li>1. \u9879\u76ee\u7ed3\u6784\u5efa\u8bae<\/li>\n<li>2. \u521b\u5efaWSGI\u5165\u53e3\u6587\u4ef6<\/li>\n<li>3. \u4f7f\u7528Gunicorn\u542f\u52a8<\/li>\n<\/ul>\n<\/li>\n<li>\u516b\u3001\u6027\u80fd\u8c03\u4f18<\/li>\n<li>\n<ul>\n<li>Worker\u6570\u91cf\u8ba1\u7b97<\/li>\n<li>\u5185\u5b58\u8003\u8651<\/li>\n<li>\u8d85\u65f6\u8bbe\u7f6e<\/li>\n<\/ul>\n<\/li>\n<li>\u4e5d\u3001\u65e5\u5fd7\u914d\u7f6e<\/li>\n<li>\n<ul>\n<li>\u8bbf\u95ee\u65e5\u5fd7<\/li>\n<li>\u9519\u8bef\u65e5\u5fd7<\/li>\n<\/ul>\n<\/li>\n<li>\u5341\u3001\u5e38\u89c1\u95ee\u9898\u89e3\u51b3<\/li>\n<li>\n<ul>\n<li>Worker\u8d85\u65f6<\/li>\n<li>\u5185\u5b58\u6cc4\u6f0f<\/li>\n<li>502 Bad Gateway<\/li>\n<\/ul>\n<\/li>\n<li>\u5341\u4e00\u3001\u9ad8\u7ea7\u7279\u6027<\/li>\n<li>\n<ul>\n<li>\u70ed\u91cd\u8f7d<\/li>\n<\/ul>\n<\/li>\n<li>\u5341\u4e8c\u3001\u76d1\u63a7\u4e0e\u7ef4\u62a4<\/li>\n<li>\n<ul>\n<li>\u67e5\u770b\u8fd0\u884c\u72b6\u6001<\/li>\n<li>\u4f18\u96c5\u91cd\u542f<\/li>\n<li>\u4f18\u96c5\u505c\u6b62<\/li>\n<\/ul>\n<\/li>\n<li>\u5341\u4e09\u3001\u751f\u4ea7\u73af\u5883\u5efa\u8bae<\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e00\u3001\u4ec0\u4e48\u662f Gunicorn&#xff1f;<\/h2>\n<p>Gunicorn\u662f\u4e00\u4e2a\u7eafPython\u7684WSGI HTTP\u670d\u52a1\u5668&#xff0c;\u7528\u4e8e\u8fd0\u884cPython Web\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u7b80\u5355\u6613\u7528&#xff0c;\u6027\u80fd\u826f\u597d&#xff0c;\u662f\u90e8\u7f72Flask\u3001Django\u7b49WSGI\u517c\u5bb9\u5e94\u7528\u7684\u6d41\u884c\u9009\u62e9\u3002<\/p>\n<p>WSGI\u662f Python \u5b9a\u4e49\u7684\u4e00\u4e2a\u6807\u51c6\u63a5\u53e3&#xff0c;\u7528\u4e8e\u89c4\u8303 Web \u670d\u52a1\u5668&#xff08;\u5982 Nginx\u3001Apache&#xff09;\u4e0e Python Web \u5e94\u7528&#xff08;\u5982 Flask\u3001Django&#xff09;\u4e4b\u95f4\u7684\u901a\u4fe1\u65b9\u5f0f\u3002\u5b83\u7684\u6838\u5fc3\u4f5c\u7528\u662f\u8ba9\u4e0d\u540c\u7684 Web \u670d\u52a1\u5668\u548c Python Web \u6846\u67b6\u80fd\u591f\u65e0\u7f1d\u534f\u4f5c\u3002<\/p>\n<h2>\u4e8c\u3001\u4e3a\u4ec0\u4e48\u9700\u8981Gunicorn&#xff1f;<\/h2>\n<p>\u5f00\u53d1\u670d\u52a1\u5668&#xff08;\u5982Flask\u5185\u7f6e\u7684app.run()&#xff09;\u867d\u7136\u65b9\u4fbf&#xff0c;\u4f46\u6709\u4e25\u91cd\u9650\u5236\u3002<\/p>\n<table>\n<tr>\u7279\u6027\u5f00\u53d1\u670d\u52a1\u5668Gunicorn<\/tr>\n<tbody>\n<tr>\n<td>\u5e76\u53d1\u5904\u7406<\/td>\n<td>\u5355\u7ebf\u7a0b<\/td>\n<td>\u591aworker\u8fdb\u7a0b<\/td>\n<\/tr>\n<tr>\n<td>\u6027\u80fd<\/td>\n<td>\u4f4e&#xff08;\u7ea6\u6bcf\u79d2\u51e0\u5341\u4e2a\u8bf7\u6c42&#xff09;<\/td>\n<td>\u9ad8&#xff08;\u53ef\u5904\u7406\u6570\u5343\u8bf7\u6c42&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u7a33\u5b9a\u6027<\/td>\n<td>\u4e0d\u9002\u5408\u957f\u65f6\u95f4\u8fd0\u884c<\/td>\n<td>\u751f\u4ea7\u7ea7\u7a33\u5b9a\u6027<\/td>\n<\/tr>\n<tr>\n<td>\u914d\u7f6e\u9009\u9879<\/td>\n<td>\u6709\u9650<\/td>\n<td>\u4e30\u5bcc\u7684\u8c03\u4f18\u9009\u9879<\/td>\n<\/tr>\n<tr>\n<td>\u8bf7\u6c42\u961f\u5217<\/td>\n<td>\u65e0<\/td>\n<td>\u667a\u80fd\u8bf7\u6c42\u961f\u5217\u7ba1\u7406<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u4e09\u3001\u5b89\u88c5Gunicorn<\/h2>\n<p>pip <span class=\"token function\">install<\/span> gunicorn<\/p>\n<h2>\u56db\u3001\u57fa\u672c\u4f7f\u7528<\/h2>\n<h3>\u542f\u52a8\u6700\u7b80\u5355\u7684Gunicorn\u670d\u52a1\u5668<\/h3>\n<p>\u5047\u8bbe\u4f60\u7684Flask\u5e94\u7528\u4e3b\u6587\u4ef6\u662fapp.py&#xff0c;\u5176\u4e2d\u5305\u542b\u4e00\u4e2a\u540d\u4e3aapp\u7684Flask\u5b9e\u4f8b&#xff1a;<\/p>\n<p>gunicorn -w <span class=\"token number\">4<\/span> -b <span class=\"token number\">127.0<\/span>.0.1:8000 app:app<\/p>\n<p>\u53c2\u6570\u8bf4\u660e -w 4: \u4f7f\u75284\u4e2aworker\u8fdb\u7a0b -b 127.0.0.1:8000: \u7ed1\u5b9a\u5230127.0.0.1\u76848000\u7aef\u53e3 app:app: \u7b2c\u4e00\u4e2aapp\u662f\u6a21\u5757\u540d&#xff08;app.py&#xff09;&#xff0c;\u7b2c\u4e8c\u4e2aapp\u662fFlask\u5b9e\u4f8b\u540d<\/p>\n<p>app <span class=\"token operator\">&#061;<\/span> Flask<span class=\"token punctuation\">(<\/span>__name__<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8fd9\u4e2a\u53d8\u91cf\u540d&#096;app&#096;\u5c31\u662f\u7b2c\u4e8c\u4e2a&#096;app&#096;\u6240\u6307\u7684\u5bf9\u8c61<\/span><\/p>\n<p>\u5982\u679c\u4f60\u7684\u6587\u4ef6\u662fmyapp.py\u4e14\u5b9e\u4f8b\u53d8\u91cf\u540d\u4e3aapplication&#xff0c;\u5219\u547d\u4ee4\u5e94\u4e3a&#xff1a;<\/p>\n<p>gunicorn -w <span class=\"token number\">4<\/span> -b <span class=\"token number\">127.0<\/span>.0.1:8000 myapp:application<\/p>\n<p>\u5e38\u7528\u547d\u4ee4\u884c\u53c2\u6570<\/p>\n<table>\n<tr>\u53c2\u6570\u8bf4\u660e\u793a\u4f8b<\/tr>\n<tbody>\n<tr>\n<td>-w, &#8211;workers<\/td>\n<td>worker\u8fdb\u7a0b\u6570<\/td>\n<td>-w 4<\/td>\n<\/tr>\n<tr>\n<td>-b, &#8211;bind<\/td>\n<td>\u7ed1\u5b9a\u5730\u5740\u548c\u7aef\u53e3<\/td>\n<td>-b 0.0.0.0:8000<\/td>\n<\/tr>\n<tr>\n<td>-k, &#8211;worker-class<\/td>\n<td>worker\u7c7b\u578b<\/td>\n<td>-k gevent<\/td>\n<\/tr>\n<tr>\n<td>&#8211;timeout<\/td>\n<td>worker\u8d85\u65f6\u65f6\u95f4(\u79d2)<\/td>\n<td>&#8211;timeout 120<\/td>\n<\/tr>\n<tr>\n<td>&#8211;log-level<\/td>\n<td>\u65e5\u5fd7\u7ea7\u522b<\/td>\n<td>&#8211;log-level debug<\/td>\n<\/tr>\n<tr>\n<td>&#8211;access-logfile<\/td>\n<td>\u8bbf\u95ee\u65e5\u5fd7\u6587\u4ef6<\/td>\n<td>&#8211;access-logfile &#8211; (\u8f93\u51fa\u5230stdout)<\/td>\n<\/tr>\n<tr>\n<td>&#8211;error-logfile<\/td>\n<td>\u9519\u8bef\u65e5\u5fd7\u6587\u4ef6<\/td>\n<td>&#8211;error-logfile &#8211; (\u8f93\u51fa\u5230stdout)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u4e94\u3001Worker\u7c7b\u578b<\/h2>\n<p>Gunicorn\u652f\u6301\u591a\u79cdworker\u7c7b\u578b&#xff0c;\u9002\u7528\u4e8e\u4e0d\u540c\u573a\u666f&#xff1a; sync (\u9ed8\u8ba4): \u540c\u6b65worker&#xff0c;\u6bcf\u4e2a\u8bf7\u6c42\u4e00\u4e2a\u8fdb\u7a0b&#xff0c;\u9002\u5408CPU\u5bc6\u96c6\u578b\u4efb\u52a1 gevent: \u57fa\u4e8e\u534f\u7a0b\u7684\u5f02\u6b65worker&#xff0c;\u9002\u5408IO\u5bc6\u96c6\u578b\u5e94\u7528 eventlet: \u7c7b\u4f3cgevent\u7684\u5f02\u6b65worker tornado: \u4f7f\u7528Tornado\u6846\u67b6\u7684\u5f02\u6b65worker gthread: \u4f7f\u7528\u7ebf\u7a0b\u7684worker&#xff0c;\u9700\u8981\u5173\u6ce8\u7ebf\u7a0b\u5b89\u5168\u95ee\u9898<\/p>\n<p>\u9009\u62e9\u5efa\u8bae CPU\u5bc6\u96c6\u578b: sync\u6216\u589e\u52a0worker\u6570\u91cf IO\u5bc6\u96c6\u578b: gevent\u6216eventlet<\/p>\n<p>gunicorn -k gevent -w <span class=\"token number\">4<\/span> app:app<\/p>\n<p>Worker \u4e4b\u95f4\u76f8\u4e92\u9694\u79bb&#xff0c;\u4e00\u4e2a Worker \u5d29\u6e83\u4e0d\u4f1a\u76f4\u63a5\u5f71\u54cd\u5176\u4ed6 Worker&#xff08;\u4e3b\u8fdb\u7a0b\u4f1a\u91cd\u542f\u5d29\u6e83\u7684 Worker&#xff09;\u3002 Gunicorn \u7684\u4e3b\u8fdb\u7a0b&#xff08;Master&#xff09;\u8d1f\u8d23\u76d1\u542c\u7aef\u53e3\u3001\u7ba1\u7406 Worker&#xff0c;\u5e76\u5c06\u8bf7\u6c42\u8f6e\u8be2\u5206\u914d\u7ed9\u7a7a\u95f2\u7684 Worker\u3002 Worker \u662f\u5b9e\u9645\u5e72\u6d3b\u7684\u8fdb\u7a0b&#xff0c;\u6570\u91cf&#xff08;-w&#xff09;\u548c\u7c7b\u578b&#xff08;-k&#xff09;\u76f4\u63a5\u5f71\u54cd\u5e76\u53d1\u80fd\u529b\u3002<\/p>\n<h2>\u516d\u3001\u914d\u7f6e\u6587\u4ef6<\/h2>\n<p>\u5bf9\u4e8e\u66f4\u590d\u6742\u7684\u914d\u7f6e&#xff0c;\u53ef\u4ee5\u4f7f\u7528\u914d\u7f6e\u6587\u4ef6&#xff08;\u901a\u5e38\u547d\u540d\u4e3agunicorn.conf.py&#xff09;&#xff1a;<\/p>\n<p><span class=\"token comment\"># gunicorn.conf.py<\/span><\/p>\n<p>bind <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;0.0.0.0:8000&#034;<\/span><br \/>\nworkers <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">4<\/span><br \/>\nworker_class <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;gevent&#034;<\/span><br \/>\ntimeout <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">120<\/span><br \/>\naccesslog <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;-&#034;<\/span>  <span class=\"token comment\"># \u8f93\u51fa\u5230stdout<\/span><br \/>\nerrorlog <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;-&#034;<\/span>   <span class=\"token comment\"># \u8f93\u51fa\u5230stdout<\/span><\/p>\n<p>\u7136\u540e\u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u542f\u52a8&#xff1a;<\/p>\n<p>gunicorn -c gunicorn.conf.py app:app<\/p>\n<h2>\u4e03\u3001\u4e0eFlask\u7ed3\u5408\u5b9e\u8df5<\/h2>\n<h3>1. \u9879\u76ee\u7ed3\u6784\u5efa\u8bae<\/h3>\n<p>myapp\/<br \/>\n\u251c\u2500\u2500 app\/              # \u5e94\u7528\u5305<br \/>\n\u2502   \u251c\u2500\u2500 __init__.py   # \u521b\u5efaapp\u5b9e\u4f8b<br \/>\n\u2502   \u251c\u2500\u2500 views.py      # \u8def\u7531\u548c\u89c6\u56fe<br \/>\n\u2502   \u2514\u2500\u2500 &#8230;<br \/>\n\u251c\u2500\u2500 gunicorn.conf.py  # Gunicorn\u914d\u7f6e<br \/>\n\u2514\u2500\u2500 wsgi.py           # WSGI\u5165\u53e3\u70b9<\/p>\n<h3>2. \u521b\u5efaWSGI\u5165\u53e3\u6587\u4ef6<\/h3>\n<p>wsgi.py\u5185\u5bb9&#xff1a;<\/p>\n<p><span class=\"token keyword\">from<\/span> app <span class=\"token keyword\">import<\/span> create_app  <span class=\"token comment\"># \u5047\u8bbe\u4f60\u7684app\u5de5\u5382\u51fd\u6570\u540d\u4e3acreate_app<\/span><\/p>\n<p>app <span class=\"token operator\">&#061;<\/span> create_app<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">if<\/span> __name__ <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token string\">&#034;__main__&#034;<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    app<span class=\"token punctuation\">.<\/span>run<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<h3>3. \u4f7f\u7528Gunicorn\u542f\u52a8<\/h3>\n<p>gunicorn -c gunicorn.conf.py wsgi:app<\/p>\n<h2>\u516b\u3001\u6027\u80fd\u8c03\u4f18<\/h2>\n<h3>Worker\u6570\u91cf\u8ba1\u7b97<\/h3>\n<p>\u7ecf\u9a8c\u516c\u5f0f&#xff1a;<\/p>\n<p>workers &#061; (2 * CPU\u6838\u5fc3\u6570) &#043; 1<\/p>\n<h3>\u5185\u5b58\u8003\u8651<\/h3>\n<p>\u6bcf\u4e2aworker\u90fd\u4f1a\u52a0\u8f7d\u5b8c\u6574\u7684Python\u5e94\u7528&#xff0c;\u786e\u4fdd\u670d\u52a1\u5668\u6709\u8db3\u591f\u5185\u5b58&#xff1a;<\/p>\n<p>\u603b\u5185\u5b58 \u2248 (worker\u6570\u91cf \u00d7 \u5355\u4e2aworker\u5185\u5b58) &#043; \u7cfb\u7edf\u5f00\u9500<\/p>\n<h3>\u8d85\u65f6\u8bbe\u7f6e<\/h3>\n<p>\u6839\u636e\u5e94\u7528\u54cd\u5e94\u65f6\u95f4\u8c03\u6574&#xff1a;<\/p>\n<p>timeout &#061; 120  # \u79d2<\/p>\n<h2>\u4e5d\u3001\u65e5\u5fd7\u914d\u7f6e<\/h2>\n<h3>\u8bbf\u95ee\u65e5\u5fd7<\/h3>\n<p>accesslog <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;\/var\/log\/gunicorn\/access.log&#034;<\/span><br \/>\naccess_log_format <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;%(h)s %(l)s %(u)s %(t)s &#034;%(r)s&#034; %(s)s %(b)s &#034;%(f)s&#034; &#034;%(a)s&#034;&#039;<\/span><\/p>\n<h3>\u9519\u8bef\u65e5\u5fd7<\/h3>\n<p>errorlog <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;\/var\/log\/gunicorn\/error.log&#034;<\/span><br \/>\nloglevel <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;info&#034;<\/span><br \/>\ncapture_output <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">True<\/span>  <span class=\"token comment\"># \u6355\u83b7stdout\/stderr<\/span><\/p>\n<h2>\u5341\u3001\u5e38\u89c1\u95ee\u9898\u89e3\u51b3<\/h2>\n<h3>Worker\u8d85\u65f6<\/h3>\n<p>\u9519\u8bef\u4fe1\u606f:<\/p>\n<p>[CRITICAL] WORKER TIMEOUT<\/p>\n<p>\u89e3\u51b3\u65b9\u6848:<\/p>\n<ul>\n<li>\u589e\u52a0timeout\u503c<\/li>\n<li>\u4f18\u5316\u5e94\u7528\u6027\u80fd<\/li>\n<li>\u8003\u8651\u4f7f\u7528\u5f02\u6b65worker<\/li>\n<\/ul>\n<h3>\u5185\u5b58\u6cc4\u6f0f<\/h3>\n<p>\u73b0\u8c61&#xff1a;\u5185\u5b58\u4f7f\u7528\u6301\u7eed\u589e\u957f \u89e3\u51b3\u65b9\u6848&#xff1a;<\/p>\n<ul>\n<li>\u5b9a\u671f\u91cd\u542fworker<\/li>\n<li>\u4f7f\u7528max_requests\u548cmax_requests_jitter\u53c2\u6570<\/li>\n<\/ul>\n<h3>502 Bad Gateway<\/h3>\n<p>\u53ef\u80fd\u539f\u56e0&#xff1a;<\/p>\n<ul>\n<li>Gunicorn\u672a\u8fd0\u884c<\/li>\n<li>Nginx\u914d\u7f6e\u9519\u8bef<\/li>\n<li>\u7aef\u53e3\u4e0d\u5339\u914d<\/li>\n<\/ul>\n<p>\u68c0\u67e5\u6b65\u9aa4&#xff1a;<\/p>\n<ul>\n<li>\u786e\u8ba4Gunicorn\u662f\u5426\u8fd0\u884c&#xff1a;ps aux | grep gunicorn<\/li>\n<li>\u68c0\u67e5Nginx\u9519\u8bef\u65e5\u5fd7&#xff1a;\/var\/log\/nginx\/error.log<\/li>\n<li>\u786e\u8ba4\u7aef\u53e3\u914d\u7f6e\u4e00\u81f4<\/li>\n<\/ul>\n<h2>\u5341\u4e00\u3001\u9ad8\u7ea7\u7279\u6027<\/h2>\n<h3>\u70ed\u91cd\u8f7d<\/h3>\n<p>\u5f00\u53d1\u65f6\u81ea\u52a8\u91cd\u8f7d\u4ee3\u7801\u53d8\u5316&#xff0c;\u4f46\u751f\u4ea7\u73af\u5883\u4e2d\u4e0d\u5efa\u8bae\u4f7f\u7528\u8fd9\u4e2a\u529f\u80fd&#xff0c;\u56e0\u4e3a\u5b83\u4f1a\u5f71\u54cd\u6027\u80fd\u3002<\/p>\n<p>gunicorn &#8211;reload app:app<\/p>\n<h2>\u5341\u4e8c\u3001\u76d1\u63a7\u4e0e\u7ef4\u62a4<\/h2>\n<h3>\u67e5\u770b\u8fd0\u884c\u72b6\u6001<\/h3>\n<p>pstree -ap <span class=\"token operator\">|<\/span> <span class=\"token function\">grep<\/span> gunicorn<\/p>\n<h3>\u4f18\u96c5\u91cd\u542f<\/h3>\n<p><span class=\"token function\">kill<\/span> -HUP <span class=\"token operator\">&lt;<\/span>master_pid<span class=\"token operator\">&gt;<\/span><\/p>\n<h3>\u4f18\u96c5\u505c\u6b62<\/h3>\n<p><span class=\"token function\">kill<\/span> &#8211;<span class=\"token environment constant\">TERM<\/span> <span class=\"token operator\">&lt;<\/span>master_pid<span class=\"token operator\">&gt;<\/span><\/p>\n<h2>\u5341\u4e09\u3001\u751f\u4ea7\u73af\u5883\u5efa\u8bae<\/h2>\n<ul>\n<li>\u4e0d\u8981\u4f7f\u7528root\u8fd0\u884c&#xff1a;\u521b\u5efa\u4e13\u7528\u7528\u6237<\/li>\n<li>\u4f7f\u7528\u8fdb\u7a0b\u7ba1\u7406\u5668&#xff1a;\u5982systemd\u6216supervisor<\/li>\n<li>\u914d\u7f6e\u65e5\u5fd7\u8f6e\u8f6c&#xff1a;\u4f7f\u7528logrotate<\/li>\n<li>\u8bbe\u7f6e\u8d44\u6e90\u9650\u5236&#xff1a;\u9632\u6b62\u5185\u5b58\u6cc4\u6f0f\u5f71\u54cd\u7cfb\u7edf<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb720\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf19\u6b21\u3002Gunicorn\u662f\u4e00\u4e2a\u7eafPython\u7684WSGI HTTP\u670d\u52a1\u5668\uff0c\u7528\u4e8e\u8fd0\u884cPython Web\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u4ecb\u7ecd\u4e86Gunicorn\u7684\u4f7f\u7528\u65b9\u6cd5\u7684\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1032,81,5937],"topic":[],"class_list":["post-56982","post","type-post","status-publish","format-standard","hentry","category-server","tag-gunicorn","tag-python","tag-5937"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python WSGI HTTP \u670d\u52a1\u5668 Gunicorn\u4ecb\u7ecd - \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\/56982.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python WSGI HTTP \u670d\u52a1\u5668 Gunicorn\u4ecb\u7ecd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb720\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf19\u6b21\u3002Gunicorn\u662f\u4e00\u4e2a\u7eafPython\u7684WSGI HTTP\u670d\u52a1\u5668\uff0c\u7528\u4e8e\u8fd0\u884cPython Web\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u4ecb\u7ecd\u4e86Gunicorn\u7684\u4f7f\u7528\u65b9\u6cd5\u7684\u6ce8\u610f\u4e8b\u9879\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/56982.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-14T20:04:46+00:00\" \/>\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=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/56982.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/56982.html\",\"name\":\"Python WSGI HTTP \u670d\u52a1\u5668 Gunicorn\u4ecb\u7ecd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-14T20:04:46+00:00\",\"dateModified\":\"2025-08-14T20:04:46+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/56982.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/56982.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/56982.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python WSGI HTTP \u670d\u52a1\u5668 Gunicorn\u4ecb\u7ecd\"}]},{\"@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":"Python WSGI HTTP \u670d\u52a1\u5668 Gunicorn\u4ecb\u7ecd - \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\/56982.html","og_locale":"zh_CN","og_type":"article","og_title":"Python WSGI HTTP \u670d\u52a1\u5668 Gunicorn\u4ecb\u7ecd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb720\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf19\u6b21\u3002Gunicorn\u662f\u4e00\u4e2a\u7eafPython\u7684WSGI HTTP\u670d\u52a1\u5668\uff0c\u7528\u4e8e\u8fd0\u884cPython Web\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u4ecb\u7ecd\u4e86Gunicorn\u7684\u4f7f\u7528\u65b9\u6cd5\u7684\u6ce8\u610f\u4e8b\u9879\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/56982.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-14T20:04:46+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/56982.html","url":"https:\/\/www.wsisp.com\/helps\/56982.html","name":"Python WSGI HTTP \u670d\u52a1\u5668 Gunicorn\u4ecb\u7ecd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-14T20:04:46+00:00","dateModified":"2025-08-14T20:04:46+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/56982.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/56982.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/56982.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Python WSGI HTTP \u670d\u52a1\u5668 Gunicorn\u4ecb\u7ecd"}]},{"@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\/56982","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=56982"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/56982\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=56982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=56982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=56982"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=56982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}