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

  • NGINX Cookbook
  • Tim Butler
  • 135字
  • 2021-07-03 00:04:30

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 '';
}
}
主站蜘蛛池模板: 襄城县| 宜丰县| 浦县| 凤城市| 西乌珠穆沁旗| 马鞍山市| 潜江市| 正蓝旗| 普兰县| 资源县| 莆田市| 海原县| 剑河县| 台州市| 甘洛县| 新建县| 中卫市| 建宁县| 金昌市| 苏尼特右旗| 宁城县| 如东县| 德州市| 平江县| 景东| 麻阳| 林口县| 福清市| 通榆县| 莒南县| 常德市| 耒阳市| 武穴市| 广宁县| 开封县| 连城县| 莲花县| 日照市| 阳江市| 化州市| 湖北省|