Friday, July 15, 2016

deploy django with nginx

hi everyone:

I am tring to deploy my site by nginx and uwagi
in my project yaohang,i have these files:

#yaohang_uwsgi.ini
[uwsgi] 
socket = :8001 
chmod-socket    = 664
master = true 
module = yaohang_uwsgi 
processes = 8 
listen = 120 
enable-threads = true 
daemonize = /home/wangwei/yaohang/yaohang_uwsgi.log 
pidfile = /home/wangwei/yaohang/yaohang_uwsgi.pid 
pythonpath = /home/wangwei/yaohang/ 
pythonpath = /home/wangwei/yaohang/yaohang_uwsgi 
pythonpath = /home/wangwei/yaohang/yaohang 
buffer-size = 32768 
reload-mercy = 8 
vacuum = true

#yaohang_uwsgi.py
import os 
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "yaohang.settings") 

from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application()

#yaohang_uwsgi.conf
server { 
listen      8000;
server_name    192.168.70.32; # this is my server's addr
charset UTF-8; 

client_max_body_size 75M; 

location / { 
include uwsgi_params; 
uwsgi_pass 127.0.0.1:8001; 
uwsgi_read_timeout 2; 
}    
location /static { 
expires 30d; 
autoindex on; 
add_header Cache-Control private; 
alias /home/wangwei/yaohang/static/; 

}   

run nginx and 
>>uwsgi --http 192.168.70.32:8001 --wsgi-file yaohang_uwsgi.py

and then by my client browser:192.168.70.32:8000
it show:502 Bad Gateway

and with the message in file /var/log/nginx/error.log :
connect() to unix:///home/wangwei/yaohang/yaohang.sock failed (13: Permission denied) while connecting to upstream, client: 192.168.71.3, server: 192.168.70.32, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///home/wangwei/yaohang/yaohang.sock:", host: "192.168.70.32:8000"

who can tell me where is wrong?

thank you!

wblueboat
 

No comments:

Post a Comment