{"id":121025,"date":"2026-11-02T00:00:46","date_gmt":"2026-11-01T16:00:46","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/121025.html"},"modified":"2026-11-02T00:00:46","modified_gmt":"2026-11-01T16:00:46","slug":"flask-%e5%8d%9a%e5%ae%a2%e8%85%be%e8%ae%af%e4%ba%91-cvm-%e9%83%a8%e7%bd%b2%e5%ae%9e%e6%88%98","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/121025.html","title":{"rendered":"Flask \u535a\u5ba2\u817e\u8baf\u4e91 CVM \u90e8\u7f72\u5b9e\u6218"},"content":{"rendered":"<h2>Flask \u535a\u5ba2\u817e\u8baf\u4e91 CVM \u90e8\u7f72\u5b9e\u6218&#xff1a;VPC \u89c4\u5212\u3001Gunicorn &#043; Nginx \u53cd\u5411\u4ee3\u7406\u4e0e 80 \u7aef\u53e3\u62d2\u7edd\u6392\u67e5<\/h2>\n<p>\u672c\u6587\u8bb0\u5f55\u4e00\u4e2a Flask \u4e2a\u4eba\u535a\u5ba2&#xff08;my_blog_V1.3&#xff09;\u4ece\u817e\u8baf\u4e91 VPC\/\u5b50\u7f51\u89c4\u5212&#xff0c;\u5230 CVM \u521b\u5efa\u3001Gunicorn \u751f\u4ea7\u5e38\u9a7b\u3001Nginx \u53cd\u5411\u4ee3\u7406\u914d\u7f6e&#xff0c;\u518d\u5230\u516c\u7f51\u8bbf\u95ee\u88ab\u62d2\u7edd\u7684\u5b8c\u6574\u6392\u67e5\u8fc7\u7a0b\u3002\u4e0d\u6ee1\u8db3\u4e8e\u201c\u547d\u4ee4\u80fd\u8dd1\u901a\u201d&#xff0c;\u91cd\u70b9\u89e3\u91ca \u4e3a\u4ec0\u4e48\u5f00\u53d1\u670d\u52a1\u5668\u4e0d\u80fd\u76f4\u63a5\u625b\u751f\u4ea7\u6d41\u91cf\u3001 Systemd \u6258\u7ba1 Gunicorn \u65f6 Unix socket \u4e0e TCP \u7aef\u53e3\u7684\u53d6\u820d\u3001 X-Forwarded-Proto \u4e0e ProxyFix \u4e3a\u4ec0\u4e48\u5fc5\u987b\u6210\u5bf9\u51fa\u73b0&#xff0c;\u4ee5\u53ca\u90e8\u7f72\u540e\u6d4f\u89c8\u5668\u62a5 ERR_CONNECTION_REFUSED \u65f6\u5982\u4f55\u7528\u201c\u670d\u52a1\u2014\u56de\u73af\u2014\u534f\u8bae\u2014\u5b89\u5168\u7ec4\u201d\u56db\u5c42\u6cd5\u9010\u7ea7\u5b9a\u4f4d\u3002\u9002\u5408\u6b63\u5728\u628a Flask \u9879\u76ee\u642c\u4e0a\u4e91\u670d\u52a1\u5668\u3001\u5e0c\u671b\u4e00\u6b21\u628a\u5730\u57fa\u642d\u7a33\u7684\u8bfb\u8005\u53c2\u8003\u3002<\/p>\n<h3>\u4e00\u3001\u817e\u8baf\u4e91\u7f51\u7edc\u89c4\u5212&#xff1a;VPC\u3001\u5b50\u7f51\u4e0e\u5b89\u5168\u7ec4\u7684\u8fb9\u754c<\/h3>\n<h4>1.1 \u5730\u57df\u9009\u62e9&#xff1a;\u4e3a\u4ec0\u4e48\u5fc5\u987b\u548c CVM \u4fdd\u6301\u4e00\u81f4<\/h4>\n<p>VPC\u3001\u5b50\u7f51\u3001\u5b89\u5168\u7ec4\u5747\u4e3a\u5730\u57df\u7ea7\u8d44\u6e90&#xff0c;A \u5730\u57df\u7684 VPC \u65e0\u6cd5\u76f4\u63a5\u627f\u8f7d B \u5730\u57df\u7684 CVM\u3002\u540c\u5730\u57df\u5185 CVM\u3001\u5b89\u5168\u7ec4\u3001\u5f39\u6027\u516c\u7f51 IP \u8d70\u5185\u7f51\u4e92\u901a&#xff0c;\u5ef6\u8fdf\u4f4e\u4e14\u4e0d\u8ba1\u6d41\u91cf\u8d39&#xff1b;\u8de8\u5730\u57df\u53ea\u80fd\u8d70\u516c\u7f51&#xff0c;\u5ef6\u8fdf\u548c\u6210\u672c\u540c\u65f6\u4e0a\u5347\u3002\u56e0\u6b64\u672c\u6b21\u90e8\u7f72\u56fa\u5b9a\u5728\u540c\u4e00\u5730\u57df\u5185\u5b8c\u6210\u3002<\/p>\n<h4>1.2 VPC \u4e0e\u5b50\u7f51&#xff1a;\u4e24\u5c42\u9694\u79bb\u7684\u5b9e\u9645\u542b\u4e49<\/h4>\n<table>\n<tr>\u5c42\u7ea7\u4f5c\u7528\u57df\u672c\u6b21\u53d6\u503c<\/tr>\n<tbody>\n<tr>\n<td>VPC<\/td>\n<td>\u5730\u57df\u7ea7&#xff0c;\u72ec\u7acb\u79c1\u6709\u7f51\u7edc<\/td>\n<td>10.0.0.0\/16<\/td>\n<\/tr>\n<tr>\n<td>\u5b50\u7f51<\/td>\n<td>\u53ef\u7528\u533a\u7ea7&#xff0c;\u7ed1\u5b9a\u5177\u4f53 AZ<\/td>\n<td>10.0.0.0\/24<\/td>\n<\/tr>\n<tr>\n<td>CVM \u5185\u7f51 IP<\/td>\n<td>\u4ece\u5b50\u7f51\u7f51\u6bb5\u5206\u914d<\/td>\n<td>10.0.0.11<\/td>\n<\/tr>\n<tr>\n<td>\u5b50\u7f51\u5fc5\u987b\u4e0e CVM \u7684\u53ef\u7528\u533a\u4e00\u81f4&#xff0c;\u56e0\u4e3a\u5b50\u7f51\u672c\u8eab\u5c31\u662f\u53ef\u7528\u533a\u7ea7\u8d44\u6e90&#xff0c;CVM \u53ea\u80fd\u653e\u5165\u76f8\u540c\u53ef\u7528\u533a\u7684\u5b50\u7f51\u3002\u5185\u7f51 IP 10.0.0.11 \u6b63\u662f\u5728 10.0.0.0\/24 \u7f51\u6bb5\u5185\u5206\u914d\u7684\u5730\u5740\u3002<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u907f\u5751\u8bf4\u660e&#xff1a;\u5982\u679c CVM \u521b\u5efa\u540e\u624d\u53d1\u73b0\u5b50\u7f51\u9009\u9519\u4e86\u53ef\u7528\u533a&#xff0c;\u5b9e\u4f8b\u65e0\u6cd5\u539f\u5730\u6302\u8f7d\u5230\u53e6\u4e00\u4e2a\u5b50\u7f51&#xff0c;\u9700\u8981\u91cd\u5efa\u5b9e\u4f8b\u3002\u89c4\u5212\u9636\u6bb5\u5148\u628a VPC \u2192 \u5b50\u7f51 \u2192 \u53ef\u7528\u533a\u8fd9\u6761\u94fe\u8def\u5b9a\u4e0b\u6765&#xff0c;\u6bd4\u4e8b\u540e\u8865\u6551\u6210\u672c\u4f4e\u5f97\u591a\u3002<\/p>\n<h4>1.3 \u5b89\u5168\u7ec4&#xff1a;VPC \u5185\u7684\u72b6\u6001\u5316\u9632\u706b\u5899<\/h4>\n<p>\u5b89\u5168\u7ec4\u53ea\u5bf9\u5f53\u524d VPC \u5185\u7684\u5b9e\u4f8b\u751f\u6548&#xff0c;\u9ed8\u8ba4\u5165\u7ad9\u7b56\u7565\u62d2\u7edd\u5927\u90e8\u5206\u7aef\u53e3\u3002\u90e8\u7f72\u524d\u9700\u8981\u660e\u786e\u4e24\u7ec4\u89c4\u5219&#xff1a;<\/p>\n<ul>\n<li>\u5df2\u653e\u884c&#xff1a;SSH 22&#xff0c;\u7528\u4e8e\u8fdc\u7a0b\u767b\u5f55&#xff1b;<\/li>\n<li>\u5f85\u653e\u884c&#xff1a;TCP 80&#xff0c;Nginx \u5bf9\u5916\u63d0\u4f9b\u7f51\u9875\u8bbf\u95ee\u3002<\/li>\n<\/ul>\n<p>\u5b89\u5168\u7ec4\u89c4\u5219\u7684\u4f5c\u7528\u8303\u56f4\u662f\u5b9e\u4f8b\u7ea7\u522b&#xff0c;\u4fee\u6539\u540e\u5373\u65f6\u751f\u6548&#xff0c;\u4e0d\u9700\u8981\u91cd\u542f CVM\u3002\u4f46\u5165\u7ad9\u89c4\u5219\u7684\u6388\u6743\u5bf9\u8c61\u9700\u8981\u663e\u5f0f\u6307\u5b9a&#xff0c;\u6f0f\u914d 0.0.0.0\/0 \u6216\u6307\u5b9a\u4e86\u9519\u8bef\u7684\u6e90 IP \u6bb5&#xff0c;\u90fd\u4f1a\u5bfc\u81f4\u516c\u7f51\u8bf7\u6c42\u5728\u5230\u8fbe Nginx \u4e4b\u524d\u5c31\u88ab\u62e6\u622a\u3002<\/p>\n<h3>\u4e8c\u3001CVM \u521b\u5efa\u4e0e\u7cfb\u7edf\u521d\u59cb\u5316<\/h3>\n<p>\u5b9e\u4f8b\u89c4\u683c\u4e3a 2 \u6838 2G\u3001\u5e26\u5bbd 3 Mbps&#xff0c;\u955c\u50cf Ubuntu 22.04 LTS 64-bit&#xff0c;\u79c1\u6709\u7f51\u7edc\u548c\u5b50\u7f51\u6cbf\u7528\u7b2c\u4e00\u6b65\u7684\u9009\u62e9&#xff0c;\u516c\u7f51\u4fa7\u5206\u914d\u5f39\u6027\u516c\u7f51 IP\u3002\u521b\u5efa\u5b8c\u6210\u540e\u5f97\u5230\u516c\u7f51 IP 106.52.34.17\u3001\u5185\u7f51 IP 10.0.0.11&#xff0c;\u901a\u8fc7 SSH 22 \u7aef\u53e3\u4ee5 root \u767b\u5f55\u3002<br \/>\n\u65f6\u533a\u5efa\u8bae\u7edf\u4e00\u4e3a Asia\/Shanghai&#xff0c;\u907f\u514d\u65e5\u5fd7\u65f6\u95f4\u4e0e\u64cd\u4f5c\u65f6\u95f4\u5bf9\u4e0d\u4e0a&#xff1a;<\/p>\n<p>timedatectl set-timezone Asia\/Shanghai<\/p>\n<h3>\u4e09\u3001\u73af\u5883\u51c6\u5907&#xff1a;\u9694\u79bb\u4e0e\u4f9d\u8d56\u4e00\u6b21\u5230\u4f4d<\/h3>\n<h4>3.1 \u7cfb\u7edf\u66f4\u65b0\u4e0e\u57fa\u7840\u4f9d\u8d56<\/h4>\n<p><span class=\"token function\">apt<\/span> update <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">apt<\/span> upgrade <span class=\"token parameter variable\">-y<\/span><br \/>\n<span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> python3 python3-pip python3-venv nginx <span class=\"token parameter variable\">-y<\/span><\/p>\n<p>\u5347\u7ea7\u8fc7\u7a0b\u4e2d\u5982\u679c\u51fa\u73b0\u670d\u52a1\u91cd\u542f\u5f39\u7a97&#xff0c;\u53ea\u52fe\u9009 nginx.service&#xff0c;\u5176\u4f59\u670d\u52a1\u4fdd\u6301\u73b0\u72b6&#xff0c;\u907f\u514d\u5728\u90e8\u7f72\u524d\u5f15\u5165\u65e0\u5173\u53d8\u66f4\u3002<\/p>\n<h4>3.2 \u62c9\u53d6\u6e90\u7801\u5e76\u521b\u5efa\u865a\u62df\u73af\u5883<\/h4>\n<p><span class=\"token builtin class-name\">cd<\/span> \/root<br \/>\n<span class=\"token function\">git<\/span> clone https:\/\/github.com\/Wasd2490\/my_blog_V1.3.git<br \/>\n<span class=\"token builtin class-name\">cd<\/span> my_blog_V1.3<br \/>\npython3 <span class=\"token parameter variable\">-m<\/span> venv venv<br \/>\n<span class=\"token builtin class-name\">source<\/span> venv\/bin\/activate<br \/>\npip <span class=\"token function\">install<\/span> flask gunicorn<\/p>\n<p>\u8fd9\u91cc\u4e00\u6b21\u6027\u5b89\u88c5 gunicorn&#xff0c;\u662f\u4e3a\u4e86\u540e\u7eed Systemd \u7684 ExecStart \u53ef\u4ee5\u76f4\u63a5\u6307\u5411\u865a\u62df\u73af\u5883\u5185\u7684\u7edd\u5bf9\u8def\u5f84&#xff0c;\u4e0d\u4f9d\u8d56 Shell \u7684 PATH\u3002\u865a\u62df\u73af\u5883\u5728\u8fd9\u91cc\u7684\u5b9e\u9645\u4f5c\u7528\u4e0d\u662f\u201c\u6574\u6d01\u201d&#xff0c;\u800c\u662f\u8ba9\u670d\u52a1\u542f\u52a8\u65f6\u89e3\u91ca\u5668\u8def\u5f84\u786e\u5b9a\u5316&#xff0c;\u907f\u514d\u7cfb\u7edf Python \u5347\u7ea7\u6216\u4f9d\u8d56\u53d8\u52a8\u5bfc\u81f4\u670d\u52a1\u884c\u4e3a\u6f02\u79fb\u3002<\/p>\n<h4>3.3 \u6570\u636e\u5e93&#xff1a;\u5df2\u6709 site.db \u65f6\u4e0d\u8981\u753b\u86c7\u6dfb\u8db3<\/h4>\n<p>\u9879\u76ee\u81ea\u5e26 SQLite \u6587\u4ef6 site.db\u3002\u5982\u679c\u4ee3\u7801\u4e2d\u6ca1\u6709\u901a\u8fc7\u5de5\u5382\u51fd\u6570\u521d\u59cb\u5316 db \u5bf9\u8c61&#xff0c;\u5f3a\u884c\u6267\u884c db.create_all() \u53ef\u80fd\u89e6\u53d1 from app import db \u7684\u5bfc\u5165\u9519\u8bef\u3002\u5728 SQLite \u6587\u4ef6\u5df2\u7ecf\u5b58\u5728\u7684\u60c5\u51b5\u4e0b&#xff0c;\u8df3\u8fc7\u5efa\u8868\u662f\u5408\u7406\u7684&#xff0c;\u90e8\u7f72\u9636\u6bb5\u5e94\u5c3d\u91cf\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u5199\u64cd\u4f5c\u3002<\/p>\n<h3>\u56db\u3001\u4ece\u5f00\u53d1\u670d\u52a1\u5668\u5230\u751f\u4ea7\u5e38\u9a7b&#xff1a;\u4e3a\u4ec0\u4e48\u5fc5\u987b\u6362\u6389 python3 app.py<\/h3>\n<h4>4.1 \u5f00\u53d1\u670d\u52a1\u5668\u6d4b\u8bd5&#xff1a;\u53ea\u9a8c\u8bc1\u5e94\u7528\u672c\u8eab\u53ef\u542f\u52a8<\/h4>\n<p>python3 app.py<\/p>\n<p>\u770b\u5230 Running on 0.0.0.0:5000 \u8bf4\u660e\u4ee3\u7801\u548c\u4f9d\u8d56\u6ca1\u6709\u786c\u6027\u7f3a\u5931&#xff0c;Ctrl&#043;C \u7ec8\u6b62\u3002Flask \u81ea\u5e26\u7684\u5f00\u53d1\u670d\u52a1\u5668\u662f\u5355\u7ebf\u7a0b\u3001\u540c\u6b65\u963b\u585e\u7684\u8bbe\u8ba1&#xff0c;\u6ca1\u6709 worker \u8fdb\u7a0b\u7ba1\u7406&#xff0c;\u4e5f\u6ca1\u6709\u5d29\u6e83\u81ea\u52a8\u91cd\u542f\u673a\u5236\u3002\u5373\u4f7f\u4ea4\u7ed9 systemd \u6258\u7ba1&#xff0c;\u672c\u8d28\u4e5f\u53ea\u662f\u628a\u5f00\u53d1\u670d\u52a1\u5668\u53d8\u6210\u4e86\u5b88\u62a4\u8fdb\u7a0b&#xff0c;\u751f\u4ea7\u7a33\u5b9a\u6027\u4e0d\u4f1a\u56e0\u6b64\u6539\u5584\u3002<\/p>\n<h4>4.2 \u7528 Gunicorn \u505a WSGI \u670d\u52a1\u5668&#xff0c;\u5e76\u9009\u62e9 Unix socket<\/h4>\n<p>2 \u6838 2G \u7684\u914d\u7f6e&#xff0c;worker \u4e0d\u9700\u8981\u5f00\u5927\u3002Gunicorn \u7684\u7ecf\u5178\u8d77\u70b9\u662f 2 \u00d7 CPU \u6838\u5fc3\u6570 &#043; 1&#xff0c;\u4f46\u5c0f\u5185\u5b58\u673a\u5668\u4e0a 2 \u4e2a worker \u66f4\u7a33\u59a5&#xff0c;\u5f00\u8fc7\u591a\u53cd\u800c\u589e\u52a0\u5185\u5b58\u538b\u529b\u3002\u751f\u4ea7\u73af\u5883\u4f18\u5148\u4f7f\u7528 Unix socket \u800c\u4e0d\u662f TCP \u7aef\u53e3&#xff1a;socket \u6587\u4ef6\u53ea\u5728\u672c\u673a\u6587\u4ef6\u7cfb\u7edf\u4e2d\u53ef\u89c1&#xff0c;\u4e0d\u7ecf\u8fc7\u7f51\u7edc\u534f\u8bae\u6808&#xff0c;\u6743\u9650\u4e5f\u53ef\u4ee5\u901a\u8fc7\u6587\u4ef6\u7cfb\u7edf\u76f4\u63a5\u63a7\u5236\u3002<br \/>\n\u5148\u5728\u524d\u53f0\u9a8c\u8bc1 Gunicorn \u80fd\u62c9\u8d77\u5e94\u7528\u5e76\u521b\u5efa socket&#xff1a;<\/p>\n<p>gunicorn <span class=\"token parameter variable\">&#8211;bind<\/span> unix:\/run\/myblog.sock <span class=\"token parameter variable\">&#8211;workers<\/span> <span class=\"token number\">2<\/span> app:app<\/p>\n<p>\u786e\u8ba4\u65e0\u8bef\u540e Ctrl&#043;C \u7ec8\u6b62&#xff0c;\u8fdb\u5165 Systemd \u914d\u7f6e\u3002<\/p>\n<h4>4.3 Systemd \u670d\u52a1\u6587\u4ef6&#xff1a;\u6258\u7ba1 Gunicorn&#xff0c;\u800c\u975e Flask \u5f00\u53d1\u670d\u52a1\u5668<\/h4>\n<p>\u521b\u5efa \/etc\/systemd\/system\/myblog.service&#xff1a;<\/p>\n<p>[Unit]<br \/>\nDescription&#061;my_blog_V1.3 Flask Blog (Gunicorn)<br \/>\nAfter&#061;network.target<br \/>\n[Service]<br \/>\nUser&#061;root<br \/>\nGroup&#061;www-data<br \/>\nWorkingDirectory&#061;\/root\/my_blog_V1.3<br \/>\nExecStart&#061;\/root\/my_blog_V1.3\/venv\/bin\/gunicorn \\\\<br \/>\n    &#8211;workers 2 \\\\<br \/>\n    &#8211;bind unix:\/run\/myblog.sock \\\\<br \/>\n    &#8211;access-logfile \/var\/log\/myblog\/access.log \\\\<br \/>\n    &#8211;error-logfile \/var\/log\/myblog\/error.log \\\\<br \/>\n    app:app<br \/>\nRestart&#061;on-failure<br \/>\nRestartSec&#061;5<br \/>\n[Install]<br \/>\nWantedBy&#061;multi-user.target<\/p>\n<p>\u4e09\u4e2a\u9700\u8981\u8bf4\u660e\u7684\u914d\u7f6e\u70b9&#xff1a;<br \/>\n\u7b2c\u4e00&#xff0c;ExecStart \u4f7f\u7528\u865a\u62df\u73af\u5883\u5185\u7684 gunicorn \u7edd\u5bf9\u8def\u5f84&#xff0c;Systemd \u4e0d\u4f9d\u8d56\u4ea4\u4e92\u5f0f shell \u7684\u73af\u5883\u53d8\u91cf&#xff0c;\u91cd\u542f\u540e\u4e5f\u80fd\u627e\u5230\u6b63\u786e\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<br \/>\n\u7b2c\u4e8c&#xff0c;\u65e5\u5fd7\u663e\u5f0f\u843d\u76d8\u5230 \/var\/log\/myblog\/\u3002\u5982\u679c\u4e0d\u6307\u5b9a&#xff0c;Gunicorn \u7684\u8bbf\u95ee\u65e5\u5fd7\u548c\u9519\u8bef\u65e5\u5fd7\u4f1a\u8fdb\u5165 journald&#xff0c;\u540e\u7eed\u914d\u5408 logrotate \u505a\u8f6e\u8f6c\u65f6\u4e0d\u5982\u72ec\u7acb\u6587\u4ef6\u76f4\u89c2\u3002<br \/>\n\u7b2c\u4e09&#xff0c;User&#061;root \u5728\u5f53\u524d\u8def\u5f84&#xff08;\/root\/my_blog_V1.3&#xff09;\u4e0b\u662f\u8fc7\u6e21\u9009\u62e9\u3002\u66f4\u89c4\u8303\u7684\u505a\u6cd5\u662f\u4f7f\u7528\u975e\u7279\u6743\u7528\u6237&#xff0c;\u4f46\u524d\u63d0\u662f\u9879\u76ee\u76ee\u5f55\u3001site.db \u548c\u4e0a\u4f20\u76ee\u5f55\u90fd\u5bf9\u8be5\u7528\u6237\u53ef\u8bfb\u5199&#xff1b;\u5426\u5219\u4f1a\u9047\u5230\u53d1\u6587\u6216\u4e0a\u4f20\u65f6 500 \u7684\u6743\u9650\u95ee\u9898\u3002Gunicorn \u5b98\u65b9\u660e\u786e\u4e0d\u5efa\u8bae\u4ee5 root \u8fd0\u884c&#xff0c;\u8fd9\u4e00\u6b65\u5e94\u5f53\u4f5c\u4e3a\u540e\u7eed\u6536\u6743\u9650\u7684\u8d77\u70b9&#xff0c;\u800c\u4e0d\u662f\u7ec8\u70b9\u3002<br \/>\n\u521b\u5efa\u65e5\u5fd7\u76ee\u5f55\u5e76\u542f\u52a8&#xff1a;<\/p>\n<p><span class=\"token function\">mkdir<\/span> <span class=\"token parameter variable\">-p<\/span> \/var\/log\/myblog<br \/>\nsystemctl daemon-reload<br \/>\nsystemctl start myblog<br \/>\nsystemctl <span class=\"token builtin class-name\">enable<\/span> myblog<br \/>\nsystemctl status myblog<\/p>\n<p>active (running) \u4e14 \/run\/myblog.sock \u5b58\u5728&#xff0c;\u8bf4\u660e Gunicorn \u5df2\u5728 Systemd \u4e0b\u5e38\u9a7b\u3002<\/p>\n<p>\u5751\u70b9&#xff1a;\u670d\u52a1\u5360\u7528 5000 \u7aef\u53e3\u6216 socket \u540e&#xff0c;\u518d\u6b21\u524d\u53f0\u6267\u884c python3 app.py \u4f1a\u51fa\u73b0 Address already in use&#xff0c;\u8fd9\u662f\u7aef\u53e3\/socket \u51b2\u7a81&#xff0c;\u4e0d\u662f\u5e94\u7528\u6545\u969c\u3002<\/p>\n<h3>\u4e94\u3001Nginx \u53cd\u5411\u4ee3\u7406&#xff1a;proxy_set_header \u4e0d\u53ea\u662f\u8f6c\u53d1 Host<\/h3>\n<p>\u4fee\u6539 \/etc\/nginx\/sites-available\/default&#xff1a;<\/p>\n<p>server {<br \/>\n    listen 80;<br \/>\n    server_name _;<br \/>\n    location \/ {<br \/>\n        proxy_pass http:\/\/unix:\/run\/myblog.sock;<br \/>\n        proxy_set_header Host $host;<br \/>\n        proxy_set_header X-Real-IP $remote_addr;<br \/>\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br \/>\n        proxy_set_header X-Forwarded-Proto $scheme;<br \/>\n    }<br \/>\n}<\/p>\n<p>proxy_pass \u6307\u5411 Unix socket&#xff0c;\u4e0e Gunicorn \u7684 &#8211;bind \u4fdd\u6301\u4e00\u81f4\u3002\u5173\u952e\u8865\u5145\u662f X-Forwarded-Proto $scheme &#xff1a;\u8fd9\u4e2a\u5934\u544a\u8bc9 Flask\u201c\u5ba2\u6237\u7aef\u5230 Nginx \u4e4b\u95f4\u7528\u7684\u662f HTTP \u8fd8\u662f HTTPS\u201d\u3002\u5982\u679c\u540e\u7eed\u914d\u7f6e SSL \u8bc1\u4e66\u65f6\u7f3a\u5c11\u5b83&#xff0c;Nginx \u867d\u7136\u5df2\u7ecf\u505a\u4e86 TLS \u7ec8\u6b62&#xff0c;Flask \u4ecd\u4f1a\u628a\u6bcf\u4e2a\u8bf7\u6c42\u5f53\u6210 HTTP&#xff0c;\u5bfc\u81f4\u540e\u53f0\u56de\u8df3\u3001\u7edd\u5bf9\u94fe\u63a5\u548c\u91cd\u5b9a\u5411\u751f\u6210\u9519\u8bef\u7684\u534f\u8bae\u524d\u7f00&#xff0c;\u4e25\u91cd\u65f6\u51fa\u73b0\u91cd\u5b9a\u5411\u6b7b\u5faa\u73af\u3002<br \/>\n\u6821\u9a8c\u5e76\u91cd\u542f&#xff1a;<\/p>\n<p>nginx <span class=\"token parameter variable\">-t<\/span><br \/>\nsystemctl restart nginx<br \/>\nsystemctl status nginx<\/p>\n<h3>\u516d\u3001\u516c\u7f51\u8bbf\u95ee\u6392\u67e5&#xff1a;ERR_CONNECTION_REFUSED \u7684\u56db\u5c42\u5b9a\u4f4d\u6cd5<\/h3>\n<p>\u6d4f\u89c8\u5668\u8bbf\u95ee\u516c\u7f51 IP \u62a5\u8fde\u63a5\u62d2\u7edd\u65f6&#xff0c;\u4e0d\u8981\u6025\u4e8e\u4fee\u6539 Nginx&#xff0c;\u6309\u4ee5\u4e0b\u987a\u5e8f\u9010\u5c42\u6392\u9664\u3002<\/p>\n<h4>\u7b2c\u4e00\u5c42&#xff1a;\u8fdb\u7a0b\u662f\u5426\u5728\u8dd1<\/h4>\n<p>systemctl status myblog \u548c systemctl status nginx \u5747\u4e3a active (running)&#xff0c;\u8fdb\u7a0b\u5c42\u6392\u9664\u3002<\/p>\n<h4>\u7b2c\u4e8c\u5c42&#xff1a;\u672c\u673a\u56de\u73af\u662f\u5426\u901a<\/h4>\n<p><span class=\"token function\">curl<\/span> <span class=\"token parameter variable\">-I<\/span> http:\/\/127.0.0.1<\/p>\n<p>\u672c\u5730 curl \u6b63\u5e38&#xff0c;\u8bf4\u660e Nginx \u2192 Gunicorn \u7684\u4ee3\u7406\u94fe\u8def\u662f\u901a\u7684&#xff0c;\u95ee\u9898\u4e0d\u5728\u5e94\u7528\u6216 Nginx \u914d\u7f6e\u672c\u8eab\u3002<\/p>\n<h4>\u7b2c\u4e09\u5c42&#xff1a;\u534f\u8bae\u662f\u5426\u5339\u914d<\/h4>\n<p>\u5982\u679c\u6d4f\u89c8\u5668\u5730\u5740\u680f\u662f https:\/\/106.52.34.17&#xff0c;\u800c\u5f53\u524d Nginx \u53ea\u76d1\u542c 80 \u7aef\u53e3\u3001\u5c1a\u672a\u914d\u7f6e SSL \u8bc1\u4e66&#xff0c;\u5c31\u4f1a\u76f4\u63a5\u5f97\u5230 ERR_CONNECTION_REFUSED\u3002\u6392\u67e5\u65f6\u9996\u5148\u786e\u8ba4\u8bbf\u95ee\u7684\u662f http:\/\/ \u800c\u4e0d\u662f https:\/\/&#xff0c;\u8fd9\u662f\u201c\u914d\u7f6e\u5168\u5bf9\u4f46\u6253\u4e0d\u5f00\u201d\u6700\u5e38\u89c1\u7684\u539f\u56e0\u4e4b\u4e00\u3002<\/p>\n<h4>\u7b2c\u56db\u5c42&#xff1a;\u5b89\u5168\u7ec4\u4e0e\u672c\u673a\u9632\u706b\u5899<\/h4>\n<p>\u5982\u679c\u524d\u4e09\u5c42\u90fd\u6b63\u5e38\u4f46\u516c\u7f51\u4ecd\u7136\u62d2\u7edd&#xff0c;\u51e0\u4e4e\u53ef\u4ee5\u65ad\u5b9a\u662f\u5b89\u5168\u7ec4\u5165\u7ad9\u89c4\u5219\u672a\u653e\u884c TCP 80\u3002\u5904\u7406\u65b9\u5f0f&#xff1a;<\/p>\n<li>\u817e\u8baf\u4e91\u63a7\u5236\u53f0 \u2192 \u5bf9\u5e94 VPC \u5b89\u5168\u7ec4 \u2192 \u5165\u7ad9\u89c4\u5219 \u2192 \u6dfb\u52a0 TCP:80&#xff0c;\u6388\u6743\u8303\u56f4 0.0.0.0\/0&#xff1b;<\/li>\n<li>\u5982\u679c Ubuntu \u672c\u673a\u542f\u7528\u4e86 ufw&#xff0c;\u540c\u6b65\u653e\u884c&#xff1a;<\/li>\n<p>ufw status<br \/>\nufw allow <span class=\"token number\">80<\/span>\/tcp<\/p>\n<p>\u8fd9\u5957\u56db\u5c42\u6cd5\u7684\u6709\u6548\u6027\u5728\u4e8e&#xff0c;\u5b83\u628a\u201c\u8fde\u63a5\u62d2\u7edd\u201d\u62c6\u6210\u4e86\u56db\u4e2a\u5f7c\u6b64\u72ec\u7acb\u7684\u5047\u8bbe&#xff1a;\u8fdb\u7a0b\u5728\u4e0d\u5728\u3001\u56de\u73af\u901a\u4e0d\u901a\u3001\u534f\u8bae\u5bf9\u4e0d\u5bf9\u3001\u7f51\u7edc\u89c4\u5219\u653e\u6ca1\u653e\u3002\u9010\u5c42\u6392\u9664\u6bd4\u53cd\u590d\u6539\u914d\u7f6e\u66f4\u7701\u65f6\u95f4\u3002<\/p>\n<h3>\u4e03\u3001\u90e8\u7f72\u7ed3\u679c\u4e0e\u4f18\u5316\u4f18\u5148\u7ea7<\/h3>\n<p>\u5f53\u524d\u72b6\u6001&#xff1a;<\/p>\n<ul>\n<li>\u2705 VPC\u3001\u5b50\u7f51\u3001\u5730\u57df\u89c4\u5212\u5b8c\u6210&#xff0c;CVM \u4e0e\u7f51\u7edc\u8d44\u6e90\u540c\u5730\u57df\u540c\u53ef\u7528\u533a<\/li>\n<li>\u2705 CVM \u521b\u5efa\u3001\u7cfb\u7edf\u521d\u59cb\u5316\u5b8c\u6210<\/li>\n<li>\u2705 \u865a\u62df\u73af\u5883\u3001\u4f9d\u8d56\u5c31\u4f4d&#xff0c;SQLite \u6570\u636e\u5e93\u65e0\u9700\u8fc1\u79fb\u5efa\u8868<\/li>\n<li>\u2705 Gunicorn \u5728 Systemd \u4e0b\u5e38\u9a7b&#xff0c;Unix socket \u7ed1\u5b9a&#xff0c;\u5f02\u5e38\u81ea\u52a8\u91cd\u542f<\/li>\n<li>\u2705 Nginx \u53cd\u5411\u4ee3\u7406\u672c\u5730\u94fe\u8def\u6b63\u5e38&#xff0c;\u5df2\u914d\u7f6e X-Forwarded-Proto<\/li>\n<li>\u23f3 \u5b89\u5168\u7ec4\u653e\u884c 80 \u7aef\u53e3\u540e&#xff0c;\u516c\u7f51\u53ef\u901a\u8fc7 http:\/\/106.52.34.17\/ \u8bbf\u95ee<br \/>\n\u540e\u7eed\u4f18\u5316\u7684\u4f18\u5148\u7ea7\u5efa\u8bae\u5982\u4e0b&#xff1a;<br \/>\n\u7b2c\u4e00\u4f18\u5148\u7ea7&#xff1a;\u5b89\u5168\u7ec4\u653e\u884c 80\u3002\u8fd9\u662f\u5f53\u524d\u552f\u4e00\u963b\u65ad\u516c\u7f51\u8bbf\u95ee\u7684\u56e0\u7d20&#xff0c;\u5176\u4ed6\u4f18\u5316\u5728\u6b64\u4e4b\u524d\u65e0\u6cd5\u88ab\u771f\u5b9e\u7528\u6237\u4f53\u9a8c\u5230\u3002<br \/>\n\u7b2c\u4e8c\u4f18\u5148\u7ea7&#xff1a;HTTPS \u4e0e ProxyFix \u6536\u5c3e\u3002\u7533\u8bf7\u8bc1\u4e66\u540e&#xff0c;Nginx \u589e\u52a0 listen 443 ssl&#xff0c;\u5e76\u5728 Flask \u4fa7\u542f\u7528 ProxyFix&#xff0c;\u4e14 x_proto \u7684\u53ef\u4fe1\u5c42\u6570\u5fc5\u987b\u4e0e Nginx \u5c42\u6570\u4e00\u81f4\u3002\u672c\u6587\u53ea\u6709\u4e00\u5c42 Nginx&#xff0c;\u56e0\u6b64 x_proto&#061;1&#xff1a;<\/li>\n<\/ul>\n<p><span class=\"token keyword\">from<\/span> werkzeug<span class=\"token punctuation\">.<\/span>middleware<span class=\"token punctuation\">.<\/span>proxy_fix <span class=\"token keyword\">import<\/span> ProxyFix<br \/>\napp<span class=\"token punctuation\">.<\/span>wsgi_app <span class=\"token operator\">&#061;<\/span> ProxyFix<span class=\"token punctuation\">(<\/span>app<span class=\"token punctuation\">.<\/span>wsgi_app<span class=\"token punctuation\">,<\/span> x_proto<span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> x_for<span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u5982\u679c Nginx \u524d\u9762\u8fd8\u6709\u4e00\u5c42 CDN \u6216\u8d1f\u8f7d\u5747\u8861&#xff0c;x_proto \u548c x_for \u9700\u8981\u76f8\u5e94\u589e\u52a0&#xff0c;\u5426\u5219 Flask \u4ecd\u7136\u53d6\u4e0d\u5230\u6b63\u786e\u7684\u539f\u59cb\u534f\u8bae\u548c\u5ba2\u6237\u7aef IP\u3002<br \/>\n\u7b2c\u4e09\u4f18\u5148\u7ea7&#xff1a;\u65e5\u5fd7\u8f6e\u8f6c\u4e0e\u6570\u636e\u5e93\u5907\u4efd\u3002Gunicorn \u7684\u65e5\u5fd7\u5df2\u7ecf\u72ec\u7acb\u843d\u76d8&#xff0c;\u4e0b\u4e00\u6b65\u7528 logrotate \u6309\u5927\u5c0f\u6216\u65f6\u95f4\u5207\u5272&#xff1b;SQLite \u6587\u4ef6\u867d\u7136\u7b80\u5355&#xff0c;\u4ecd\u7136\u9700\u8981\u5b9a\u65f6\u5907\u4efd&#xff0c;\u907f\u514d\u5355\u70b9\u78c1\u76d8\u6545\u969c\u5bfc\u81f4\u6570\u636e\u4e22\u5931\u3002<br \/>\n\u7b2c\u56db\u4f18\u5148\u7ea7&#xff1a;\u66ff\u6362 User&#061;root \u3002\u521b\u5efa\u4e13\u7528\u7cfb\u7edf\u7528\u6237&#xff0c;\u540c\u6b65\u8c03\u6574\u9879\u76ee\u76ee\u5f55\u3001socket \u6587\u4ef6\u548c\u65e5\u5fd7\u76ee\u5f55\u7684\u5c5e\u4e3b\u4e0e\u6743\u9650&#xff0c;\u4f7f\u670d\u52a1\u4ee5\u6700\u5c0f\u6743\u9650\u8fd0\u884c\u3002\u8fd9\u4e00\u6b65\u4e0d\u4f1a\u7acb\u523b\u6539\u53d8\u201c\u80fd\u4e0d\u80fd\u8bbf\u95ee\u201d&#xff0c;\u4f46\u5b83\u662f\u4ece\u201c\u80fd\u8dd1\u201d\u8d70\u5411\u201c\u53ef\u7ef4\u62a4\u201d\u7684\u5fc5\u8981\u52a8\u4f5c\u3002<\/p>\n<p>\u5982\u679c\u8fd9\u7bc7\u90e8\u7f72\u65e5\u5fd7\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u9ebb\u70e6\u70b9\u8d5e\u3001\u6536\u85cf&#xff0c;\u6709\u7591\u95ee\u6216\u8005\u53d1\u73b0\u95ee\u9898\u90fd\u53ef\u4ee5\u5728\u8bc4\u8bba\u533a\u7559\u8a00&#xff0c;\u8c22\u8c22\u5927\u5bb6&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Flask \u535a\u5ba2\u817e\u8baf\u4e91 CVM \u90e8\u7f72\u5b9e\u6218&#xff1a;VPC \u89c4\u5212\u3001Gunicorn  Nginx \u53cd\u5411\u4ee3\u7406\u4e0e 80 \u7aef\u53e3\u62d2\u7edd\u6392\u67e5\u672c\u6587\u8bb0\u5f55\u4e00\u4e2a Flask \u4e2a\u4eba\u535a\u5ba2&#xff08;my_blog_V1.3&#xff09;\u4ece\u817e\u8baf\u4e91 VPC\/\u5b50\u7f51\u89c4\u5212&#xff0c;\u5230 CVM \u521b\u5efa\u3001Gunicorn \u751f\u4ea7\u5e38\u9a7b\u3001Nginx \u53cd\u5411\u4ee3\u7406\u914d\u7f6e&#xff0c;\u518d\u5230\u516c\u7f51\u8bbf\u95ee\u88ab\u62d2\u7edd\u7684\u5b8c\u6574\u6392\u67e5\u8fc7\u7a0b\u3002\u4e0d\u6ee1\u8db3\u4e8e\u201c\u547d\u4ee4\u80fd\u8dd1\u901a\u201d&#xff0c;\u91cd\u70b9\u89e3\u91ca \u4e3a\u4ec0\u4e48\u5f00\u53d1\u670d\u52a1\u5668\u4e0d\u80fd\u76f4\u63a5\u625b\u751f\u4ea7\u6d41\u91cf\u3001 Syste<\/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":[153,1032,117,103,351],"topic":[],"class_list":["post-121025","post","type-post","status-publish","format-standard","hentry","category-server","tag-flask","tag-gunicorn","tag-nginx","tag-ubuntu","tag-351"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Flask \u535a\u5ba2\u817e\u8baf\u4e91 CVM \u90e8\u7f72\u5b9e\u6218 - \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\/121025.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Flask \u535a\u5ba2\u817e\u8baf\u4e91 CVM \u90e8\u7f72\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Flask \u535a\u5ba2\u817e\u8baf\u4e91 CVM \u90e8\u7f72\u5b9e\u6218&#xff1a;VPC \u89c4\u5212\u3001Gunicorn Nginx \u53cd\u5411\u4ee3\u7406\u4e0e 80 \u7aef\u53e3\u62d2\u7edd\u6392\u67e5\u672c\u6587\u8bb0\u5f55\u4e00\u4e2a Flask \u4e2a\u4eba\u535a\u5ba2&#xff08;my_blog_V1.3&#xff09;\u4ece\u817e\u8baf\u4e91 VPC\/\u5b50\u7f51\u89c4\u5212&#xff0c;\u5230 CVM \u521b\u5efa\u3001Gunicorn \u751f\u4ea7\u5e38\u9a7b\u3001Nginx \u53cd\u5411\u4ee3\u7406\u914d\u7f6e&#xff0c;\u518d\u5230\u516c\u7f51\u8bbf\u95ee\u88ab\u62d2\u7edd\u7684\u5b8c\u6574\u6392\u67e5\u8fc7\u7a0b\u3002\u4e0d\u6ee1\u8db3\u4e8e\u201c\u547d\u4ee4\u80fd\u8dd1\u901a\u201d&#xff0c;\u91cd\u70b9\u89e3\u91ca \u4e3a\u4ec0\u4e48\u5f00\u53d1\u670d\u52a1\u5668\u4e0d\u80fd\u76f4\u63a5\u625b\u751f\u4ea7\u6d41\u91cf\u3001 Syste\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/121025.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-01T16:00: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=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/121025.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/121025.html\",\"name\":\"Flask \u535a\u5ba2\u817e\u8baf\u4e91 CVM \u90e8\u7f72\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-01T16:00:46+00:00\",\"dateModified\":\"2026-11-01T16:00:46+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/121025.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/121025.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/121025.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Flask \u535a\u5ba2\u817e\u8baf\u4e91 CVM \u90e8\u7f72\u5b9e\u6218\"}]},{\"@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":"Flask \u535a\u5ba2\u817e\u8baf\u4e91 CVM \u90e8\u7f72\u5b9e\u6218 - \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\/121025.html","og_locale":"zh_CN","og_type":"article","og_title":"Flask \u535a\u5ba2\u817e\u8baf\u4e91 CVM \u90e8\u7f72\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Flask \u535a\u5ba2\u817e\u8baf\u4e91 CVM \u90e8\u7f72\u5b9e\u6218&#xff1a;VPC \u89c4\u5212\u3001Gunicorn Nginx \u53cd\u5411\u4ee3\u7406\u4e0e 80 \u7aef\u53e3\u62d2\u7edd\u6392\u67e5\u672c\u6587\u8bb0\u5f55\u4e00\u4e2a Flask \u4e2a\u4eba\u535a\u5ba2&#xff08;my_blog_V1.3&#xff09;\u4ece\u817e\u8baf\u4e91 VPC\/\u5b50\u7f51\u89c4\u5212&#xff0c;\u5230 CVM \u521b\u5efa\u3001Gunicorn \u751f\u4ea7\u5e38\u9a7b\u3001Nginx \u53cd\u5411\u4ee3\u7406\u914d\u7f6e&#xff0c;\u518d\u5230\u516c\u7f51\u8bbf\u95ee\u88ab\u62d2\u7edd\u7684\u5b8c\u6574\u6392\u67e5\u8fc7\u7a0b\u3002\u4e0d\u6ee1\u8db3\u4e8e\u201c\u547d\u4ee4\u80fd\u8dd1\u901a\u201d&#xff0c;\u91cd\u70b9\u89e3\u91ca \u4e3a\u4ec0\u4e48\u5f00\u53d1\u670d\u52a1\u5668\u4e0d\u80fd\u76f4\u63a5\u625b\u751f\u4ea7\u6d41\u91cf\u3001 Syste","og_url":"https:\/\/www.wsisp.com\/helps\/121025.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-01T16:00:46+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/121025.html","url":"https:\/\/www.wsisp.com\/helps\/121025.html","name":"Flask \u535a\u5ba2\u817e\u8baf\u4e91 CVM \u90e8\u7f72\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-01T16:00:46+00:00","dateModified":"2026-11-01T16:00:46+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/121025.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/121025.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/121025.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Flask \u535a\u5ba2\u817e\u8baf\u4e91 CVM \u90e8\u7f72\u5b9e\u6218"}]},{"@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\/121025","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=121025"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/121025\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=121025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=121025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=121025"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=121025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}