时间:2021-07-01 10:21:17 帮助过:13人阅读
vim uwsgi.ini
[uwsgi]
socket = /tmp/t1.sock
pidfile = /tmp/t1.pid
plugins = python
pythonpath = /var/www
#项目python环境virtualenv = /var/www/env
#项目的跟路径pythonpath = /var/www/my_flask
chdir = /var/www/my_flask
#日志文件daemonize = /var/www/my_flask/web.log
chmod-socket = 666
master = true
#启动的进程processes = 4
#环境变量env=PYTH/t1
env=LANG=zh_CN.UTF-8
env=LC_ALL=zh_CN.UTF-8
#flask app的 py文件module = index
#app的 py文件里面的app对象callable = app
max-requests = 500000
#运行的用户gid = www-data
uid = www-data
ignore-sigpipe = true
enable-threads = true
测试的index.py
from flask import Flask
app = Flask(__name__)
@app.route("/")defhello():return"Hello World!
运行
#以www-data用户运行 uwsgi
sudo -u www-data uwsgi --ini uwsgi.ini
#运行后会生成socket文件root@ubuntu:/var/www/my_flask# ll /tmp/t1*
-rw-r--r-- 1 www-data www-data 5Mar2110:13 /tmp/t1.pid
srw-rw-rw- 1 www-data www-data 0Mar2110:13 /tmp/t1.sock=
nginx配置
server {
...
location / {
include uwsgi_params;
uwsgi_pass unix:///tmp/t1.sock; #这为生成的sock文件
}
...
}
').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i <= lines; i++) {
$numbering.append($('').text(i));
};
$numbering.fadeIn(1700);
});
});
以上就介绍了nginx+wsgi+flask配置,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。