繁体   English   中英

与nginx + uwsgi + django有502错误

[英]502 error with nginx + uwsgi +django

我试图在nginx和uwsgi上配置django,并且在尝试访问localhost时遇到502错误的网关错误

这是我的/ 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;
    }
}

这是我在/ 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  

这是uwsgi.log文件

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 - 编译
版本:4.6.2于2012年2月20日10:06:16周二7月10日21:49:38
2012年 - 当前工作目录:/ Tue Jul 10 21:49:38 2012 - 写作
pidfile到/ run / uwsgi / app / testapp1 / pid 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
2012年1月21:49 - 你的内存页面大小是4096字节星期二7月10日
2012年21:49:38 - uwsgi socket 0绑定到UNIX地址
/ run / uwsgi / app / testapp1 / socket fd 5 Tue Jul 10 21:49:38 2012 - bind():
没有这样的文件或目录[socket.c第107行]

我没有更改nginx.conf文件。

其他情况是它是一个权限问题(不是像你的情况下的套接字路径拼写错误)。 在这种情况下,您可以将此添加到uwsgi ini文件中

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

错误消息足够清楚:

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]

你看到以下区别:

 socket = /run/uwsgi/testapp1/socket

和:

 uwsgi_pass unix:///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