- NGINX Cookbook
- Tim Butler
- 135字
- 2021-07-03 00:04:30
How to do it...
- 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
- 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 '';
}
}
推薦閱讀
- ASP.NET Web API:Build RESTful web applications and services on the .NET framework
- Java Web開發學習手冊
- GraphQL學習指南
- Azure IoT Development Cookbook
- Building a RESTful Web Service with Spring
- 實戰Java程序設計
- PHP+MySQL網站開發項目式教程
- 人人都懂設計模式:從生活中領悟設計模式(Python實現)
- 程序設計基礎教程:C語言
- 自學Python:編程基礎、科學計算及數據分析(第2版)
- INSTANT JQuery Flot Visual Data Analysis
- LabVIEW數據采集
- Raspberry Pi Blueprints
- Google Adsense優化實戰
- Developing Java Applications with Spring and Spring Boot