首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Nginx在静态内容上拒绝13与Django的权限

Nginx在静态内容上拒绝13与Django的权限
EN

Stack Overflow用户
提问于 2013-04-15 12:10:25
回答 2查看 7.1K关注 0票数 3

我使用这个教程来设置一个虚拟服务器和nginx服务器。我照别人说的做了,但我还是得到了一个

拒绝许可(13)

试图访问静态内容时出错。我已经将静态dir和整个Django项目设置为www-data所有。

此外,如果我忽略静态内容,并试图让一切运行与皇帝,我会遇到更多的许可被拒绝的错误。现在我每次试着访问这个网站。

代码语言:javascript
运行
复制
root      8704  0.0  0.0  62780  1260 ?        Ss   16:19   0:00 nginx: master process /usr/sbin/nginx
www-data  8705  0.0  0.0  63108  1680 ?        S    16:19   0:00 nginx: worker process
www-data  8706  0.0  0.0  63108  1680 ?        S    16:19   0:00 nginx: worker process
www-data  8707  0.0  0.0  63108  1680 ?        S    16:19   0:00 nginx: worker process
www-data  8708  0.0  0.0  63448  2276 ?        S    16:19   0:00 nginx: worker process

当使用www-data启动uwsgi时,当启动uwsgi:https://gist.github.com/anonymous/f19997fd07c0237a7435为根时:

代码语言:javascript
运行
复制
root@vmd2719:~/energy1/energydrinks# uwsgi --ini django.ini --uid www-data --gid www-data
[uWSGI] getting INI configuration from django.ini
open("./python27_plugin.so"): No such file or directory [core/utils.c line 3321]
!!! UNABLE to load uWSGI plugin: ./python27_plugin.so: cannot open shared object file: No such file or directory !!!
*** Starting uWSGI 1.9.6 (64bit) on [Mon Apr 15 16:24:49 2013] ***
compiled with version: 4.6.3 on 15 April 2013 11:52:36
os: Linux-3.2.0-40-generic #64-Ubuntu SMP Mon Mar 25 21:22:10 UTC 2013
nodename: vmd2719
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /root/energy1/energydrinks
writing pidfile to /tmp/energy-master.pid
detected binary path: /usr/local/bin/uwsgi
setgid() to 33
setuid() to 33
chdir(): Permission denied [core/uwsgi.c line 2063]
chdir(): Permission denied [core/uwsgi.c line 1249]
chdir(): Permission denied [core/uwsgi.c line 1269]

访问静态文件的Nginx调试日志:

代码语言:javascript
运行
复制
2013/04/15 16:20:25 [debug] 8708#0: *1 http filename: "/root/energy1/energydrinks/static/jgrowl/jquery.jgrowl.js"
2013/04/15 16:20:25 [debug] 8708#0: *1 add cleanup: 0000000001F68C10
2013/04/15 16:20:25 [error] 8708#0: *1 open() "/root/energy1/energydrinks/static/jgrowl/jquery.jgrowl.js" failed (13: Permission denied), client: 109.193.75.142, server: .de, request: "GET /static/jgrowl/jquery.jgrowl.js HTTP/1.1", host: ".de:8000", referrer: "http://.de:8000/member/register/"
2013/04/15 16:20:25 [debug] 8708#0: *1 http finalize request: 403, "/static/jgrowl/jquery.jgrowl.js?" a:1, c:1
2013/04/15 16:20:25 [debug] 8708#0: *1 http special response: 403, "/static/jgrowl/jquery.jgrowl.js?"
2013/04/15 16:20:25 [debug] 8708#0: *1 http set discard body
2013/04/15 16:20:25 [debug] 8708#0: *1 xslt filter header
2013/04/15 16:20:25 [debug] 8708#0: *1 charset: "" > "utf-8"
2013/04/15 16:20:25 [debug] 8708#0: *1 HTTP/1.1 403 Forbidden
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-04-15 14:34:17

所以你的nginx在/root内部运行.那不太好。普通用户无法访问/root (除非您chmod +x它,这是个坏主意)。

您应该在/srv/http/var/www/home/whatever中将数据移出它,而不是在/root中。

票数 8
EN

Stack Overflow用户

发布于 2013-04-15 13:12:42

如果您的nginx不在生产中,可以添加"error_log /path/ to /log debug“,然后尝试访问您的静态内容之一。您将看到nginx试图在调试文件中加载什么。应该是有用的。

不要犹豫,在这里张贴它的内容,以帮助我们理解。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16014816

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档