简体   繁体   English

与nginx + uwsgi + django有502错误

[英]502 error with nginx + uwsgi +django

I've tried to configure django on top on nginx and uwsgi and a 502 bad gateway error is encountered when trying to access localhost 我试图在nginx和uwsgi上配置django,并且在尝试访问localhost时遇到502错误的网关错误

This is my /etc/ngingx/sites-available/default file 这是我的/ etc / ngingx / sites-available / default文件

server {
    server_name testapp1.com www.testapp1.com;
    access_log /var/log/nginx/testapp1.com.access.log;

    location / {
        uwsgi_pass unix:///var/run/uwsgi/app/testapp1/socket;
        include uwsgi_params;
    }
}

This is my testapp1.ini file in /etc/nginx/apps-available/ 这是我在/ etc / nginx / apps-available /中的testapp1.ini文件

[uwsgi]  
    thread=3  
    master=1  
    env = DJANGO_SETTINGS_MODULE=testapp1.settings  
    module = django.core.handlers.wsgi:WSGIHandler()  
    chdir = /home/paul/apps/testapp1  
    socket = /run/uwsgi/testapp1/socket  
    logto = /var/log/uwsgi/testapp1.log  

This is the uwsgi.log file 这是uwsgi.log文件

Tue Jul 10 21:49:38 2012 - *** Starting uWSGI 1.0.3-debian (32bit) on Tue Jul 10 21:49:38 2012 - ***开始使用uWSGI 1.0.3-debian(32位)
[Tue Jul 10 21:49:38 2012] *** Tue Jul 10 21:49:38 2012 - compiled [Tue Jul 10 21:49:38 2012] *** Tue Jul 10 21:49:38 2012 - 编译
with version: 4.6.2 on 20 February 2012 10:06:16 Tue Jul 10 21:49:38 版本:4.6.2于2012年2月20日10:06:16周二7月10日21:49:38
2012 - current working directory: / Tue Jul 10 21:49:38 2012 - writing 2012年 - 当前工作目录:/ Tue Jul 10 21:49:38 2012 - 写作
pidfile to /run/uwsgi/app/testapp1/pid Tue Jul 10 21:49:38 2012 - pidfile到/ run / uwsgi / app / testapp1 / pid Tue Jul 10 21:49:38 2012 -
detected binary path: /usr/bin/uwsgi-core Tue Jul 10 21:49:38 2012 - 检测到二进制路径:/ usr / bin / uwsgi-core Tue Jul 10 21:49:38 2012 -
setgid() to 33 Tue Jul 10 21:49:38 2012 - setuid() to 33 Tue Jul 10 setgid()to 33 Tue Jul 10 21:49:38 2012 - setuid()to 33 Tue Jul 10
21:49:38 2012 - your memory page size is 4096 bytes Tue Jul 10 2012年1月21:49 - 你的内存页面大小是4096字节星期二7月10日
21:49:38 2012 - uwsgi socket 0 bound to UNIX address 2012年21:49:38 - uwsgi socket 0绑定到UNIX地址
/run/uwsgi/app/testapp1/socket fd 5 Tue Jul 10 21:49:38 2012 - bind(): / run / uwsgi / app / testapp1 / socket fd 5 Tue Jul 10 21:49:38 2012 - bind():
No such file or directory [socket.c line 107] 没有这样的文件或目录[socket.c第107行]

I didnt change the nginx.conf file. 我没有更改nginx.conf文件。

Other case scenario is that it is a permission problem (not a socket path misspell like in your case). 其他情况是它是一个权限问题(不是像你的情况下的套接字路径拼写错误)。 In that case u can add this to uwsgi ini file 在这种情况下,您可以将此添加到uwsgi ini文件中

[uwsgi]                                                                                                          
uid = www-data
gid = www-data
chmod-socket = 664
chown-socket = www-data

The error message is clear enough: 错误消息足够清楚:

Tue Jul 10 21:49:38 2012 - uwsgi socket 0 bound to UNIX address
/run/uwsgi/app/testapp1/socket fd 5
Tue Jul 10 21:49:38 2012 - bind():
No such file or directory [socket.c line 107]

Do you see difference between: 你看到以下区别:

 socket = /run/uwsgi/testapp1/socket

and: 和:

 uwsgi_pass unix:///var/run/uwsgi/app/testapp1/socket;

?

Hint: / var /run/uwsgi/ app /testapp1/socket 提示: / var / run / uwsgi / app / testapp1 / socket

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM