首頁 > 後端開發 > php教程 > nginx+wsgi+flask配置

nginx+wsgi+flask配置

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
發布: 2016-07-29 08:57:54
原創
1187 人瀏覽過

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>
登入後複製
').addClass('pre-numbering').hhide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介紹了nginx+wsgi+flask配置,包含了方面的內容,希望對PHP教程有興趣的朋友有所幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
php - 為什麼有的網站不帶www要跳到www
來自於 1970-01-01 08:00:00
0
0
0
ubuntu,/var/www/目錄沒寫寫權限
來自於 1970-01-01 08:00:00
0
0
0
為什麼在PHPstudy 根目錄沒有WWW?
來自於 1970-01-01 08:00:00
0
0
0
nginx https下不帶www跳轉www設置
來自於 1970-01-01 08:00:00
0
0
0
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板