2017-03-08 3 views
1

Ich versuche, Django-App von Ubuntu 14.04 nach Raspberry Pi (Rasbbian OS) für Ubuntu zu migrieren habe ich getan http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html und es hat funktioniert.uwsgi nginx Verbindung zu Unix-Socket verweigert

in raspbian ist es nicht so einfach.

das ist mein bills_nginx.conf in/etc/nginx/sites-enabled

 bills_nginx.conf 

# the upstream component nginx needs to connect to 
upstream django { 
    server unix:/var/www/html/bills/bills/bills.sock; # for a file socket 
    #server 127.0.0.1:8001; # 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 192.168.5.5; # 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 /var/www/html/bills/bills/bills/media; # your Django project's media files - amend as required 
    } 

    location /static { 
     alias /var/www/html/bills/bills/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  /var/www/html/bills/bills/uwsgi_params; # the uwsgi_params file you installed 
    } 
} 

und das ist mein uwsgi INI-Datei:

[uwsgi] 

# Django-related settings 
# the base directory (full path) 
chdir   = /var/www/html/bills/bills 
# Django's wsgi file 
module   = bills.wsgi 
# the virtualenv (full path) 
home   = /home/seb/.virtualenvs/bills3 
# process-related settings 
# master 
master   = true 
# maximum number of worker processes 
processes  = 10 
# the socket (use the full path to be safe 
socket   = /var/www/html/bills/bills/bills.sock 
# ... with appropriate permissions - may be needed 
uid =www-data 
gid=www-data 
chown-socket=www-data:www-data 
chmod-socket = 666 
# clear environment on exit 
vacuum   = true 
daemonize=/var/log/uwsgi/bills3.log 
error_log=/var/log/nginx/bills3_error.log 

in error.log ich:

2017/03/08 10:27:43 [error] 654#0: *1 connect() to unix:/var/www/html/bills/bills/bills.sock failed (111: Connection refused) while connecting to upstream, client: 192.168.5.2, server: 192.168.5.5, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/var/www/html/bills/bills/bills.sock:", host: "192.168.5.5:8000" 

mir bitte helfen, es zu bekommen arbeiten :)

+0

Wo ist dieser Teil in Ihrer nginx.conf: 'upstream django { # Server unix: ///path/to/your/mysite/mysite.sock; # für einen Datei-Socket Server 127.0.0.1:8001; # für einen Web-Port-Socket (wir verwenden das zuerst) } '? – JosefScript

Antwort

0

chmod-Buchse, chown-Buchse, gid, uid, Buchse Für uwsgi und nginx einen Sockel zu kommunizieren, müssen Sie die Berechtigungen und den Eigentümer der Steckdose spezifizieren. 777 als chmod-Buchse ist viel zu liberal für die Produktion. Allerdings müssen Sie möglicherweise mit dieser Nummer herumspielen, um sie richtig zu machen, damit alles Notwendige kommunizieren kann. Wenn Sie nicht von Ihrer Steckdose Konfigurationen kümmern, werden Sie Fehlermeldungen erhalten, wie zum Beispiel:

So stellen Sie sicher, die Erlaubnis des Ordners .. denke ich, besserer Weg

$ sudo mkdir /var/uwsgi 
$ sudo chown www-data:www-data /var/uwsgi 

And change the socket path 

upstream django { 
    server unix:/var/uwsgi/bills.sock; # for a file socket 
    #server 127.0.0.1:8001; # for a web port socket (we'll use this first) } 

Weitere Referenz: Pls Überprüfung Ein großer Artikel http://monicalent.com/blog/2013/12/06/set-up-nginx-and-uwsgi/

auch ich das gleiche Problem haben, bevor können Sie meine Konfiguration überprüfen

nginx django uwsgi page not found error

Verwandte Themen