1. 설치
apt-get install python-pip python-dev
pip install uwsgi
2. flask 코드
from flask import Flask
application = Flask(__name__)
@application.route("/")
def hello():
return "<h1>test</h1>"
if __name__ == "__main__":
application.run(host='127.0.0.1', port=9001)
3. uwsgi 설정
[uwsgi]
socket = 127.0.0.1:8000
uid = www-data gid = www-data
chdir = /var/www/flask
module = test
callable = application
master = True
pidfile = /tmp/uwsgi-flask.pid
max-requests = 5000
daemonize = /var/log/uwsgi/flask_test.log
uwsgi --ini uwsgi.ini
4. nginx 설정
server {
listen 80;
server_name flask.com;
access_log /var/log/nginx/flask-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 /test;
uwsgi_cache test;
}
}
'오픈소스 > nginx' 카테고리의 다른 글
nginx for beego (0) | 2018.02.02 |
---|---|
nginx for http2 (0) | 2018.02.02 |
nginx ssl 설정 (0) | 2018.02.02 |
nginx for express (0) | 2018.01.29 |
nginx for django (0) | 2018.01.29 |