Docker Ubuntu+NGINX+uWSGI+flask

$ docker run -p 8080:8080 -it --name flask -v /home/docks/flask:/var/www/html ubuntu

# apt-get update
# apt-get upgrade
# apt-get install vim
# apt-get install net-tools
# apt-get install nginx # Nginx
# apt-get install uwsgi # uWSGI
# apt-get install uwsgi-plugin-python # python과 uWSGI를 연결하는 플러그인

# apt-get install python3
# apt-get install python3-pip python3-dev
# pip3 install -U pip

# pip3 install virtualenv

# cd /var/www/html
# virtualenv service
# cd service
# . bin/activate
# pip3 install flask
# pip3 install uwsgi

# cd /var/www/html/service
# vi app.py
---
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
return 'Hello World!'

if __name__ == '__main__':
app.run()
---

# vi /etc/nginx/sites-available/default
---
server {
listen 8080; # 연결할 포트
server_name 0.0.0.0;
location / { try_files $uri @app; }
location @app {
include uwsgi_params;
uwsgi_pass unix:/tmp/uwsgi.sock;
}
}
---

# vi /etc/uwsgi/apps-available/uwsgi.ini
---
[uwsgi]
chdir=/var/www/html/service
chmod-socket=666
callable=app
module=app
socket=/tmp/uwsgi.sock
virtualenv=/var/www/html/service
---

# service nginx restart
# service uwsgi restart

# uwsgi /etc/uwsgi/apps-available/uwsgi.ini


https://ohienbee.blogspot.kr

댓글

이 블로그의 인기 게시물

[LINUX] CentOS 부팅시 오류 : UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY

[MSSQL] 데이터베이스가 사용 중이어서 배타적으로 액서스할 수 없습니다

구글코랩) 안전Dream 실종아동 등 검색 오픈API 소스를 공유합니다. (구글드라이브연동, 이미지 수집 소스)