Nginx+Gunicorn
설치 하 다.
sudo apt-get install nginx
시작, 정지, 재 부팅
sudo /etc/init.d/nginx start
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx restart
or
sudo service nginx start
sudo service nginx stop
sudo service nginx restart
설정 nginx
편집 / etc / nginx / sites - enabled / default 감청 포트 설정, 정적 파일 설정
vim /etc/nginx/sites-enabled/default
upstream django1 {
server unix:///home/www/company/company.sock; # for a file socket
#server 127.0.0.1:8011; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=off;
location / {
proxy_pass http://your IP:8000;#change your port
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static {
alias /your project path/static/; # your Django project's static files - amend as required
}
location /media {
alias /your project path/media; # your Django project's media files - amend as required
}
}
한 서버 에 여러 항목 을 배치 할 때 주의해 야 합 니 다.
테스트 프로필:
nginx -t
서비스 다시 시작:
sudo service nginx restart
python manage.py collectstatics
Gunicorn
설치 하 다.
pip install gunicorn
gunicorn 의 간단 한 용법:
gunicorn code:application
다 중 핵 처리 장치 에서 8 개의 프로 세 스 를 동시에 시작 하여 HTTP 요청 을 처리 합 니 다.
gunicorn -w 8 code:applcation
django +gunicorn:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# add app
'yourapp',
'gunicorn',
)
프로젝트 파일 에서 실행:
$ nohup gunicorn project.wsgi:application -b 127.0.0.1:1010&
nohup 은 파일 nohup command > my out. file 2 > & 1 & 그리고 tail 로 nohup. out 을 볼 수 있 습 니 다. 아무런 정보 도 없 으 면 됩 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.