无法使用 Django 和 apache modwsgi 上传文件
由于 html5 video 标签的一些问题,我最近不得不放弃 Django 开发服务器并转移到 apache。
尝试将视频上传到媒体文件夹时,此更改导致出现 [Errno 13] 权限被拒绝错误。
我已经使用 chmod 将媒体文件夹递归设置为 777,并使用 chgrp 向 www-data 组授予权限;这是执行 ls -lha media/ 时的输出
total 12K
drwxrwxrwx 3 esteban www-data 4,0K 2012-02-22 06:44 .
drwxr-xr-x 10 esteban esteban 4,0K 2012-02-22 07:35 ..
drwxrwxrwx 3 esteban www-data 4,0K 2012-02-13 10:12 generated
我还在 httpd.conf 文件中编写了以下指令:
<Directory /home/esteban/python_projects/video_transform/media>
Options +Indexes
Order allow,deny
Allow from all
</Directory>
这允许我在浏览到 http://localhost 时列出文件夹内容/media 但上传尚未成功。
有什么想法吗?
编辑:此行抛出异常:
destination = open('media/' + filename, 'wb+')
I recently had to drop the Django development server and moved to apache because of some problems with the html5 video tag.
The change brought a [Errno 13] Permission denied error when trying to upload a video to the media folder.
I have already set the media folder recursively to 777 with chmod and gave permissions to www-data group with chgrp; here is the output when executing ls -lha media/
total 12K
drwxrwxrwx 3 esteban www-data 4,0K 2012-02-22 06:44 .
drwxr-xr-x 10 esteban esteban 4,0K 2012-02-22 07:35 ..
drwxrwxrwx 3 esteban www-data 4,0K 2012-02-13 10:12 generated
I also wrote the following directive in the httpd.conf file:
<Directory /home/esteban/python_projects/video_transform/media>
Options +Indexes
Order allow,deny
Allow from all
</Directory>
This allows me to list the folder contents when browsing to http://localhost/media
but no success with the uploads yet.
Any ideas??
EDIT: The exception is thrown in this line:
destination = open('media/' + filename, 'wb+')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
按照评论中的建议使用绝对路径。请阅读以下文档:
http://code.google.com/p/modwsgi/ wiki/ApplicationIssues#Application_Working_Directory
了解原因。
Use an absolute path as suggested in comment. Read the documentation at:
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Application_Working_Directory
as to why.
我将测试在 Apache 配置中切换 Order 指令。在当前情况下,拒绝指令虽然没有明确定义,但位于允许指令之后并有效阻止所有流量。像这样切换 Order 指令应该可以解决问题:
I would test switching the Order directive in your Apache config. In the current case the deny directive, though not explicitly defined, comes after the Allow directive and effectively blocks all traffic. Switching the Order directive around as such should fix the issue: