i want to run django with nginx i followed this instructions and in
/etc/nginx/sites-available/cartoview_one
upstream django {
server unix:///root/cartoview_project/mysite.sock; # for a file socket }
server {
listen 80;
server_name xx.xx.xx.xx;
charset utf-8;
# max upload size
client_max_body_size 2048M; # adjust to taste
# Django media
location /media {
alias /root/cartoview_project/uploaded;
}
location /static {
alias /root/cartoview_project/static;
}
location / {
uwsgi_pass django;
include /root/cartoview_project/uwsgi_params; # the uwsgi_params file you installed
}
}
then created symlink using:
sudo ln -s /etc/nginx/sites-available/cartoview_one /etc/nginx/sites-enabled
and in project folder mysite_uwsgi.ini
:
[uwsgi]
project = cartoview_project
chdir = /root/cartoview_project
module = %(project).wsgi:application
home = /root/env
master = true
processes = 10
socket = /root/cartoview_project/mysite.sock
chmod-socket = 666
vacuum = true
http-socket = 0.0.0.0:80
project structure :
. |-- apps |-- cartoview_project | |-- __init__.py | |-- __init__.pyc | |-- local_settings.py | |-- local_settings.pyc | |-- local_settings.py.sample | |-- settings.py | |-- settings.pyc | |-- urls.py | |-- wsgi.py | `-- wsgi.pyc |-- default_oauth_apps.json |-- initial_data.json |-- manage.py |-- mysite_uwsgi.ini `-- uwsgi_params
when i try to access website with myip this message appear :
502 Bad Gateway
nginx/1.10.0 (Ubuntu)
error.log :
2017/02/06 09:46:41 [crit] 6867#6867: *1 connect() to unix:///root/cartoview_project/mysite.sock failed (13: Permission denied) while connecting to upstream, client: xx.xx.xxx.xxx, server: xxx.xxx.xxx.xxx, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///root/cartoview_project/mysite.sock:", host: "xxx.xxx.xxx.xxx"
Update :
i removed http-socket
and run the following command /root/env/bin/uwsgi --ini mysite_uwsgi.ini
and mysite.sock
appeared in project then restart nginx but nothing changed.
:~/cartoview_project# stat mysite.sock
File: 'mysite.sock'
Size: 0 Blocks: 0 IO Block: 4096 socket
Device: 802h/2050d Inode: 17172079 Links: 1
Access: (0666/srw-rw-rw-) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-02-06 10:44:56.188168371 +0100
Modify: 2017-02-06 10:44:56.188168371 +0100
Change: 2017-02-06 10:44:56.188168371 +0100
Birth: -
Machine : vps(Ubuntu 16.04) User: root
Solved :
by changing include /root/cartoview_project/uwsgi_params
to include /etc/nginx/uwsgi_params;
uwsgi --http 0.0.0.0:8134 --wsgi-file UniservedWebsite/wsgi.py &
and refer your nginx to0.0.0.0:8134
and addhttp-timeout
– Piyush S. Wanare