nginx+wsgi+flask配置

WBOY
Libérer: 2016-07-29 08:57:54
original
1161 Les gens l'ont consulté

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>
Copier après la connexion

测试的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>
Copier après la connexion

运行

<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>
Copier après la connexion

nginx配置

<code>server {
        <span>...</span>
        location / {
                include uwsgi_params;
                uwsgi_pass unix:///tmp/t1.sock; <span>#这为生成的sock文件</span>
        }
        <span>...</span>
}</code>
Copier après la connexion
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了nginx+wsgi+flask配置,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal