[PyDelhi] Help to deploy django with nginx

Raakesh kumar kumar3180 at gmail.com
Thu Jun 2 13:55:14 EDT 2016


Hi,
I am trying to deploy a Django application on Digital Ocean server with
Nginx. Here is what i have done so far:

1 - Created a file under /etc/nginx/sites-available
server {
    listen 80 default_server;
    #server_name example.com;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/sample;
    }

    location / {
        include         uwsgi_params;
        uwsgi_pass      unix:/tmp/sample.sock;
    }
}

2 - Created symlink to /etc/nginx/sites-enabled
3 - Created /etc/uwsgi/sites/sample.ini
[uwsgi]
project = sample
base = /home

chdir = %(base)/%(project)
home = %(base)/Env/%(project)
module = %(project).wsgi:application

master = true
processes = 2

socket = /tmp/sample.sock
uid = www-data
gid = www-data
chmod-socket = 777
vacuum = true
4 - And finally to start it on start created a file /etc/init/uwsgi.conf
description "uWSGI"
start on runlevel [2345]
stop on runlevel [!2345]
respawn

exec /usr/local/bin/uwsgi --master --emperor /etc/uwsgi --uid www-data
--gid www-data --logto /var/log/uwsgi.log

But when i run the server it shows bad gateway error(502)
And in the log file i see the message

2016/06/02 13:52:43 [error] 16048#0: *1 connect() to unix:/tmp/sample.sock
failed (111: Connection refused) while connecting to upstream, client:
196.207.77.55, server: , request: "GET / HTTP/1.1", upstream:
"uwsgi://unix:/tmp/sample.sock:", host: "139.59.12.129"

Any solution to solve it?

-- 
Regards
RAKESH KUMAR
http://www.raakeshkumar.in
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ncr-python.in/attachments/20160602/69524467/attachment.html>


More information about the Ncr-Python.in mailing list