官术网_书友最值得收藏!

How to do it...

  1. First up, we set up our uwsgi.ini file, which should be located in the root of your Flask application. Here's the file:
      [uwsgi]
socket = 127.0.0.1:8000
uid = www-data gid = www-data
chdir = /var/www/flaskdemo
module = demoapp
callable = application
master = True
pidfile = /tmp/uwsgi-flaskdemo.pid
max-requests = 5000
daemonize = /var/log/uwsgi/flaskdemo.log

For this demo, we have a single Flask file located in /var/www/flaskdemo/demoapp.py.

You can quickly launch your uWSGI service by running the following command:

      uwsgi --ini uwsgi.ini

 

  1. We now need to configure the NGINX server block directive and again I've included this in a separate file (/etc/nginx/conf.d/flask.conf):
      server { 
listen 80;
server_name flaskdemo.nginxcookbook.com;
access_log /var/log/nginx/flaskdemo-access.log combined;
location = /favicon.ico { access_log off; log_not_found off; }
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8000;
uwsgi_param SCRIPT_NAME '';
}
}
主站蜘蛛池模板: 合肥市| 合水县| 马边| 崇阳县| 博爱县| 阿鲁科尔沁旗| 贵溪市| 桃园县| 合阳县| 罗田县| 景谷| 黄石市| 九龙城区| 丹凤县| 凤翔县| 唐海县| 贡觉县| 哈尔滨市| 关岭| 鄢陵县| 城口县| 深水埗区| 娄烦县| 蒙阴县| 卓尼县| 那曲县| 高邑县| 公主岭市| 凭祥市| 尉犁县| 古浪县| 万全县| 巢湖市| 东阳市| 黄骅市| 固原市| 子洲县| 宽甸| 金秀| 姚安县| 台南县|