嗯,我目前正在try 使用nginx和uwsgi为我的Django应用程序提供服务.我目前使用的是安装了uwsgi的虚拟环境.但是,当我try 访问该页面时,当前收到502错误网关错误.

我正在经历的错误.

2014/02/27 14:20:48 [crit] 29947#0: *20 connect() to unix:///tmp/uwsgi.sock failed (13: Permission denied) while connecting to upstream, client: 144.136.65.176, server: domainname.com.au, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:", host: "www.domainname.com.au"

这是我的nginx.conf

    # mysite_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
    server unix:///tmp/uwsgi.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 .domainname.com.au; # 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 /home/deepc/media;  # your Django project's media files - amend as required
    }

    location /static {
        alias /home/deepc/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     /home/deepc/.virtualenvs/dcwebproj/dcweb/uwsgi_params; # the uwsgi_params file you installed
    }
}

这是我的uwsgi.ini文件

[uwsgi]
socket=/tmp/uwsgi.sock
chmod-socket=644
uid = www-data
gid = www-data

chdir=/home/deepc/.virtualenvs/dcwebproj/dcweb
module=dcweb.wsgi:application
pidfile=/home/deepc/.virtualenvs/dcwebproj/dcweb.pid
vacuum=true

我在Google上看到的是www-data组和/tmp/目录的权限问题.不过,我对此还是个新手,我曾try 更改文件夹的权限级别,但都无济于事.有人能给我指个方向吗?这是权限问题吗.

把sock文件放在tmp目录中也可以吗?

谢谢

推荐答案

我认为您只需要将套接字文件更改为666(使用www-data 664就可以了),或者删除它并再次运行uwsgi服务器.

在我的uwsgi.ini中:

chmod-socket = 664
uid = www-data
gid = www-data

Django相关问答推荐

Django相关对象引用模板

Django模型ManyToManyField.Add不起作用

如何在Django表单中传递self.请求数据?

如何在Django模板中有条件地传递值给with变量?

Django Inline Tabular admin:删除一个不工作的对象

AttributeError:模块rest_framework.serializers在 Swagger 中的 Django 中没有属性NullBooleanField

为什么 django 不能相互识别 2 个路径转换器?

Django 长时间运行带有线程/处理的异步任务

django-rest-framework 如何使模型序列化器字段成为必需

是否可以在没有模型的情况下创建自定义管理视图

Django JSONField 过滤

Python / Django 中的 Unicode 与 UTF-8 混淆?

Django App 配置不当 - 应用程序模块有多个文件系统位置

Django rest-auth allauth 注册,带有邮箱、名字和姓氏,没有用户名

在 Django 管理页面中注册应用程序中的每个表/类

UnicodeEncodeError:ascii编解码器无法编码字符

Python - 覆盖 __init__ 的最干净方法,其中在 super() 调用之后必须使用可选的 kwarg?

Django中的自定义排序

import_module 的 Django 1.9 ImportError

Django - 指定 Django 管理员应该使用哪个模型管理器