wsgi 구성 파일
<code>vim uwsgi.ini [uwsgi] <span>socket</span> = /tmp/t1.sock <span>pidfile</span> = /tmp/t1.pid <span>plugins</span> = python <span>pythonpath</span> = /var/www <span>#项目python环境</span><span>virtualenv</span> = /var/www/env <span>#项目的跟路径</span><span>pythonpath</span> = /var/www/my_flask <span>chdir</span> = /var/www/my_flask <span>#日志文件</span><span>daemonize</span> = /var/www/my_flask/web.log chmod-socket = 666 <span>master</span> = true <span>#启动的进程</span><span>processes</span> = 4 <span>#环境变量</span><span>env</span>=PYTH/t1 <span>env</span>=LANG=zh_CN.UTF-8 <span>env</span>=LC_ALL=zh_CN.UTF-8 <span>#flask app的 py文件</span><span>module</span> = index <span>#app的 py文件里面的app对象</span><span>callable</span> = app max-requests = 500000 <span>#运行的用户</span><span>gid</span> = www-data <span>uid</span> = www-data ignore-sigpipe = true enable-threads = true</code>
테스트된 index.py
<code><span>from</span> flask <span>import</span> Flask app = Flask(__name__) <span>@app.route("/")</span><span><span>def</span><span>hello</span><span>()</span>:</span><span>return</span><span>"Hello World!</span></code>
실행
<code><span>#以www-data用户运行 uwsgi </span> sudo -u www-data uwsgi --ini uwsgi.ini <span>#运行后会生成socket文件</span>root<span>@ubuntu</span><span>:/var/www/my_flask</span><span># ll /tmp/t1*</span> -rw-r--r-- <span>1</span> www-data www-data <span>5</span><span>Mar</span><span>21</span><span>10</span><span>:</span><span>13</span> /tmp/t1.pid srw-rw-rw- <span>1</span> www-data www-data <span>0</span><span>Mar</span><span>21</span><span>10</span><span>:</span><span>13</span> /tmp/t1.sock=</code>
nginx 구성
<code>server { <span>...</span> location / { include uwsgi_params; uwsgi_pass unix:///tmp/t1.sock; <span>#这为生成的sock文件</span> } <span>...</span> }</code>
위 내용은 관련 내용을 포함하여 nginx wsgi 플라스크 구성을 소개한 내용이 PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되기를 바랍니다.