权限被拒绝 - nginx 和 uwsgi 套接字 [英] Permission denied - nginx and uwsgi socket

查看:46
本文介绍了权限被拒绝 - nginx 和 uwsgi 套接字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Well I am currently trying to get my django application served using nginx and uwsgi. I am currently using a virtual environment to which uwsgi is installed. However I am currently getting a 502 bad gateway error when attempting to access the page.

我遇到的错误.

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

This is my 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 文件

Here is my uwsgi.ini file

[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

从我在谷歌上读到的内容来看,www-data 组和/tmp/目录存在权限问题.但是,我对此很陌生,并尝试更改文件夹的权限级别无济于事.有人能指出我正确的方向吗?这是权限问题吗.

From what i have read on google its a permissions problem with the www-data group and /tmp/ directory. However I am new to this and have tried to changer the permission level of the folder to no avail. Could someone point me in the right direction? Is this a permissions problem.

将sock文件放在tmp目录下也可以吗?

Also is it ok practice to put the sock file in tmp directory?

谢谢

推荐答案

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

I think you just need to change your socket file to 666(664 is ok with www-data), or remove it and run uwsgi server again.

在我的 uwsgi.ini 中:

In my uwsgi.ini:

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

这篇关于权限被拒绝 - nginx 和 uwsgi 套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆