Django 上传文件出现 OSError Permission denied的解决办法
2012-06-20 10:54
816 查看
我的服务器在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.
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.
一看发现是因为上传文件的文件夹可能没有被赋予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.
cd /var/www/media chgrp -R www-data geekingreen/ chmod -R g+w geekingreen/
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的解决方法
- github上传时出现error: src refspec master does not match any解决办法
- 使用 STM8L DISCOVERY 示例程序添加库文件出现 Error[Li005]: no definition for XXX 的解决办法
- github上传时出现error: src refspec master does not match any解决办法
- github上传时出现error: src refspec master does not match any解决办法
- 使用ajaxfileupload.js进行文件上传,出现的问题以及解决办法
- windows python flask上传文件出现IOError: [Errno 13] Permission denied: 'E:\\git\\test\\static\\uploads'的解决方法
- 神舟上网本安装一键还原精灵出现error loading os的解决办法
- firefox、chrom浏览器使用swfupload上传文件出现404错误的解决办法
- ## 本地文件上传github (坚持看到尾部,提供各种命令行error,解决办法)##
- 上传大文件,出现: 413 request Entity too Large错误的解决办法
- php和uploadify上传文件出现的问题及解决办法
- ajaxfileupload.js上传文件时jQuery.handleError is not a function的 解决办法
- Allegro16.6生成负片光绘文件,出现error的解决办法
- JQuery上传插件Uploadify出现"HTTP Error"错误的解决办法
- 关于Xcode7上传时出现error的解决办法(Http://)传输协议
- MySQL安装后出现“Error 1045(28000) Access Denied for user....."解决办法
- IIS+php环境下:上传文件出现:windows server PHP Warning: mkdir(): Permission denied 解决办法
- U-Boot中使用tftp下载文件出现错误TFTP error: 'Access violation' (2)的解决办法