django + uwsgi + supervisor + nginx 배치
yum install python-devel.x86_64 nginx supervisor gcc python-pip -y
pip install uwsgi
테스트 virtualenv Django 환경 구축
pip install virtualenv
mkdir myproject
cd myproject/
virtualenv --no-site-packages venv
source venv/bin/activate
pip install Django==1.9
django-admin startproject mysite
cd mysite/
python manage.py startapp blog
python manage.py runserver 0.0.0.0:8080
테스트 uwsgi Django 프로그램 시작
# uwsgi --http :8001 --chdir /path/to/project --home=/path/to/env --module project.wsgi
uwsgi --http :8001 --chdir /root/myproject/mysite --home=/root/myproject/venv --module mysite.wsgi
uwsgi 프로필 만 들 기
mysite-uwsgi.ini
[uwsgi]
# http = :8080
#the local unix socket file than commnuincate to Nginx
socket = 127.0.0.1:8001
# the base directory (full path)
chdir = /root/myproject/mysite
# the virtualenv directory(full path)
home = /root/myproject/venv
# Django's wsgi file
wsgi-file = mysite/wsgi.py
# maximum number of worker processes
processes = 4
#thread numbers startched in each worker process
threads = 2
#monitor uwsgi status
stats = 127.0.0.1:9191
# clear environment on exit
vacuum = true
supervisor 서비스 설정
/etc/supervisord.d/mysite.ini
[program:mysite]
command=/usr/bin/uwsgi --ini /root/myproject/mysite-uwsgi.ini
directory=/root/myproject/mysite
startsecs=0
stopwaitsecs=0
autostart=true
autorestart=true
슈퍼 바 이 저 서비스 시작
systemctl enable supervisord
systemctl start supervisord
nginx 서비스 설정
/etc/nginx/conf.d/mysite_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
# server unix:///root/myproject/mysite/mysite.sock; # for a file socket
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
server_name 192.168.75.104; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /root/myproject/mysite/media; # your Django project's media files - amend as required
}
location /static {
alias /root/myproject/mysite/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include uwsgi_params; # the uwsgi_params file you installed
}
}
nginx 서비스 시작
#
nginx -t
#
systemctl enable nginx && systemctl start nginx
참고 문서
공식 문서
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.