Django 上传文件出现 OSError Permission denied的解决办法
来源:互联网 发布:信用卡可以在淘宝套现 编辑:程序博客网 时间:2024/04/28 07:14
转载自http://blog.csdn.net/quicktest/article/details/7678994
我的服务器在Ubuntu上,使用了Apache+Nginx做App Server,Django+Python开发,今天上传文件时候出现了OSError的错误,具体原因为Permission denied
一看发现是因为上传文件的文件夹可能没有被赋予www-data用户(Apache和Nginx用户)写的权限
根据以下网站的解决办法已经解决问题了,特写此博希望能帮到大家
http://stackoverflow.com/questions/1682440/permission-denied-error-with-django-while-uploading-a-file
I just ran into this same problem. And found the solution if you are hosting with Apache as your server. For instance if my settings were:
MEDIA_ROOT = '/var/www/media/geekingreen'
then I would simply need to give that folder the correct permissions recursively to make sure that any sub-folders also have the same permission. The default group for apache is www-data so to give permission to my django app I would run these commands.
<code><span class="pln">cd </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">mediachgrp </span><span class="pun">-</span><span class="pln">R www</span><span class="pun">-</span><span class="pln">data geekingreen</span><span class="pun">/</span><span class="pln">chmod </span><span class="pun">-</span><span class="pln">R g</span><span class="pun">+</span><span class="pln">w geekingreen</span><span class="pun">/</span><span class="pln"></span></code>
The chgrp -R www-data geekingreen/ command changes the directory geekingreen and any subdirectories to have the group www-data.
The chmod -R g+w geekingreen/ command changes what permissions the group has on all of these folders that now belong to www-data, to now have the write permission. Obviously required for uploads.
Hope this can help anyone that may have had a similar problem.
- Django 上传文件出现 OSError Permission denied的解决办法
- Django 上传文件出现 OSError Permission denied的解决办法
- Django 上传文件出现 OSError Permission denied的解决方法
- 出现Permission denied的解决办法
- IIS+php环境下:上传文件出现:windows server PHP Warning: mkdir(): Permission denied 解决办法
- 向vsftp服务器上传文件报“550 Permission denied”错误的解决办法 (2012
- 向vsftp服务器上传文件报“550 Permission denied”错误的解决办法
- 向vsftp服务器上传文件报“550 Permission denied”错误的解决办法
- scp远程拷贝文件出现permission denied,please try again的解决办法
- WinSCP上传文件Permission Denied
- ubuntu 下操作目录,出现Permission denied的解决办法
- linux下出现connect failed: Permission denied错误的解决办法
- untu 下操作目录,出现Permission denied的解决办法
- ubuntu 下操作目录,出现Permission denied的解决办法
- ubuntu 下操作目录,出现Permission denied的解决办法
- ubuntu下操作目录,出现Permission denied的解决办法
- PHPMailer发送邮件出现Permission denied的解决办法
- PHPMailer发送邮件出现Permission denied的解决办法
- 一、mysql数据库的基本操作(备份、恢复数据库以及一些常用的命令)
- 几种概率分布
- 关于任哲的《嵌入式实时操作系统uC/OS II原理及应用(第二版)》开发环境搭建和第一个例子
- Hadoop 2.6.0的安装与配置
- C语言课设-班级成绩统计分析
- Django 上传文件出现 OSError Permission denied的解决办法
- C语言之辅助循环手段continue和break
- 关于Opengl各种矩阵变换的理解
- 【伤逝版 红颜劫】
- 控制执行流程
- cocos2dx[3.2] ——核心类Director/Scene/Layer/Sprite详细讲解
- is not allowed to connect to this MySql server
- java 集合类学习笔记
- 十七、斐波那契数列 【递推思想(迭代思想)解决】