간단 한 방법 으로 Flask + uwsgi + nginx 를 ubuntu 16.04 서버 에 배치 합 니 다.
1) nginx 설치
먼저 nginx 를 설치 하고 ubuntu 터미널 에서 실행 합 니 다.
ubuntu@VM-252-231-ubuntu:~$ sudo apt install nginx
설치 에 성공 하면 클 라 우 드 서버 도 메 인 이나 ip 에 접근 하면 nginx 의 기본 페이지 가 나타 날 것 입 니 다.
2) 설치 uwsgi
가상 환경 을 사용 하려 면 가상 환경 디 렉 터 리 가 프로젝트 폴 더 아래 에 있 고 설치 해 야 할 가방 이 모두 설치 되 어 있다 고 가정 합 니 다. 이름 은 venv 입 니 다. 먼저 python - dev
ubuntu@VM-252-231-ubuntu:~$ sudo apt install python-dev
를 설치 합 니 다.그리고 가상 환경 활성화:
ubuntu@VM-252-231-ubuntu:~$ source venv/bin/activate```
N , uwsgi
pip , -i ,
`(venv) ubuntu@VM-252-231-ubuntu:~/N$ pip install uwsgi -i https://pypi.douban.com/simple`
##### 3) uwsgi
uwsgi , uwsgi , :
[uwsgi] master = true home = venv
Flask 응용 실례 가 있 는 모듈
wsgi-file = manage.py
Flask 인 스 턴 스 이름
callable = app socket = 127.0.0.1:5000 stats = 127.0.0.1:9191
시스템 CPU 의 핵심 수 에 따라 결정 합 니 다.
processes = 4 threads = 4 buffer-size = 32768```
내 프로필 의 이름 은 uwsgi. ini 입 니 다. uwsgi 를 시작 하 라 는 명령 은 다음 과 같 습 니 다.
(venv) ubuntu@VM-252-231-ubuntu:~/N$ uwsgi uwsgi.ini
시작 에 성공 하면 알림 메시지 가 나타 납 니 다:*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x154fed0 pid: 3423 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 3423)
spawned uWSGI worker 1 (pid: 3428, cores: 4)
spawned uWSGI worker 2 (pid: 3429, cores: 4)
spawned uWSGI worker 3 (pid: 3430, cores: 4)
spawned uWSGI worker 4 (pid: 3431, cores: 4)
*** Stats server enabled on 0.0.0.0:9191 fd: 15 ***```
###### : uwsgi ,
uwsgi id :
`buntu@VM-252-231-ubuntu:~$ N ps -ef | grep uwsgi`
id 119911
tete 119911 117227 8 12:01 pts/20 00:00:01 uwsgi uwsgi.ini tete 119916 119911 0 12:01 pts/20 00:00:00 uwsgi uwsgi.ini tete 119917 119911 0 12:01 pts/20 00:00:00 uwsgi uwsgi.ini tete 119918 119911 0 12:01 pts/20 00:00:00 uwsgi uwsgi.ini tete 119922 119911 0 12:01 pts/20 00:00:00 uwsgi uwsgi.ini tete 119987 119933 0 12:01 pts/0 00:00:00 grep --color= auto -- exclude - dir =. bzr -- exclude - dir = CVS -- exclude - dir =. git -- exclude - dir =. hg -- exclude - dir =. svn uwsgi ` ` ` 이 프로 세 스에 SIGQUIT 를 보 내 면 uwsgi 를 닫 을 수 있 습 니 다.
buntu@VM-252-231-ubuntu:~$ kill -s SIGQUIT 119911
4) nginx 설정현재 uwsgi 라 는 웹 서버 가 시작 되 었 습 니 다. 다음은 nginx 를 설정 합 니 다.가장 쉬 운 방법 은 / etc / nginx / sites - enabled / default 파일 을 직접 편집 하여 안의 모든 내용 을 삭제 하고 다음 내용 으로 바 꾸 는 것 입 니 다.
server {
listen 80 default_server;
listen [::]:80 default_server;
root /path/to/your/project;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
uwsgi_pass 127.0.0.1:5000;
include uwsgi_params;
}
}```
, ,
`ubuntu@VM-252-231-ubuntu:~$ sudo /etc/init.d/nginx reload`
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.