我使用此tutorial设置了virtualenv和nginx服务器.我完全按照所告诉的去做,但是我仍然得到Permission denied (13)尝试访问静态内容时发生错误.我已经将我的静态目录和整个Django项目设置为www-data拥有.进一步,如果我...

我使用此tutorial设置了virtualenv和nginx服务器.
我完全按照所告诉的去做,但是我仍然得到
Permission denied (13)
尝试访问静态内容时发生错误.
我已经将我的静态目录和整个Django项目设置为www-data拥有.
进一步,如果我忽略静态内容,并尝试让所有内容都以皇帝身份运行,则会遇到更多权限被拒绝的错误.现在,每次我尝试访问该站点时.
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
启动uwsgi时:以root身份https://gist.github.com/anonymous/f19997fd07c0237a7435
使用www-data启动uwsgi时:
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调试日志访问静态文件:
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
解决方法:
因此,您的nginx在/ root内以www-data的身份运行…效果不好.普通用户不能访问/ root(除非您对它进行chmod x,这是一个坏主意).
您应该将数据移出/ srv / http,/ var / www或/ home /任何地方,而不是/ root.
本文标题为:python-静态内容上的Django拒绝Nginx权限13


基础教程推荐
- Python pygame 项目实战事件监听 2022-08-30
- python-挂钩并在Windows消息队列中记录“所有内容” 2023-11-10
- Python自动爬取图片并保存实例代码 2023-08-04
- windows主用python3 个别程序使用python2的方法 2023-09-03
- windows上安装python和python开发工具 2023-11-11
- python-day30(进程 验证空间隔离) 2023-09-04
- Python调用百度AI实现人像分割详解 2023-08-04
- Day033--Python--进程 2023-09-03
- API例子:用Python驱动Firefox采集网页数据 | 一起学习Python网络爬虫 2023-09-04
- python使用pandas读写excel文件的方法实例 2022-08-30