Django + nginx + uwsgi 배치 (linux)
* 우선
uwsgi 가 일 하 는 지 여 부 를 테스트 할 때 우 리 는 모두 xxx. py 파일 을 쓸 것 입 니 다. 다음 과 같 습 니 다.
def application(env, start_responce):
start_responce("200 OK", [('Content-Type', 'text/html')])
return [b"Hello World"] # python3
# return ["Hello World"] # python2
실행: uwsgi -- http: 8000 -- wgi - file xxx. py 후 http: 127.0.1: 8000 로그 인
* 게다가
바로 uwsgi. ini 와 nginx. conf 의 설정 입 니 다. 아래 에 제 프로필 을 붙 입 니 다.
uwsgi. ini (아래 xxx 는 당신 의 django 프로젝트 이름 입 니 다. you 는 당신 의 / home / you /)
[uwsgi]
# Django-related settings
# socket = :8000
socket = /home/you/xxx/xxx.sock
chmod-socket = 666
uid = you
gid = you
# the base directory (full path)
chdir = /home/zbl/xxx
# Django s wsgi file
module = xxx.wsgi
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 4
# clear environment on exit
vacuum = true
xxx_nginx. conf (아래 xxx 는 django 프로젝트 이름 입 니 다. you 는 자신의 / home / you /)
# xxx_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
server unix:///home/you/xxx/xxx.sock; # for a file socket
# server 127.0.0.1:8000; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name www.example.com; # 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 /path/to/your/mysite/media; # your Django project's media files - amend as required
# }
location /static {
alias /home/you/xxx/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 /home/you/xxx/uwsgi_params; # the uwsgi_params file you installed
}
}
마지막.
nginx error.log .sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: www.xxxxx.com
vim /etc/nginx/nginx.conf -> user root
-rw-rw-r-- 1 you you 664 12 20 15:21 uwsgi_params
-rw-r--r-- 1 you you 1.1K 12 20 16:14 you_nginx.conf
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.