OSError: [Errno 13] Permission denied while setting up django-filer
OSError: [Errno 13] Permission denied while setting up django-filer
我安装了 django-filer,现在正在测试上传功能,但是当我尝试上传文件时,出现以下错误:
[Fri Jul 10 11:32:20 2015] [error] ERROR Internal Server Error: /admin/filer/clipboard/operations/upload/
[Fri Jul 10 11:32:20 2015] [error] Traceback (most recent call last):
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 112, in get_response
[Fri Jul 10 11:32:20 2015] [error] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
[Fri Jul 10 11:32:20 2015] [error] return view_func(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/admin/clipboardadmin.py", line 81, in ajax_upload
[Fri Jul 10 11:32:20 2015] [error] file_obj.save()
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/models/imagemodels.py", line 56, in save
[Fri Jul 10 11:32:20 2015] [error] super(Image, self).save(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/models/abstract.py", line 65, in save
[Fri Jul 10 11:32:20 2015] [error] super(BaseImage, self).save(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/models/filemodels.py", line 165, in save
[Fri Jul 10 11:32:20 2015] [error] super(File, self).save(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/polymorphic/polymorphic_model.py", line 89, in save
[Fri Jul 10 11:32:20 2015] [error] return super(PolymorphicModel, self).save(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 545, in save
[Fri Jul 10 11:32:20 2015] [error] force_update=force_update, update_fields=update_fields)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 572, in save_base
[Fri Jul 10 11:32:20 2015] [error] self._save_parents(cls, using, update_fields)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 597, in _save_parents
[Fri Jul 10 11:32:20 2015] [error] self._save_table(cls=parent, using=using, update_fields=update_fields)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 654, in _save_table
[Fri Jul 10 11:32:20 2015] [error] result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 687, in _do_insert
[Fri Jul 10 11:32:20 2015] [error] using=using, raw=raw)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 232, in _insert
[Fri Jul 10 11:32:20 2015] [error] return insert_query(self.model, objs, fields, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 1514, in insert_query
[Fri Jul 10 11:32:20 2015] [error] return query.get_compiler(using=using).execute_sql(return_id)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 902, in execute_sql
[Fri Jul 10 11:32:20 2015] [error] for sql, params in self.as_sql():
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 860, in as_sql
[Fri Jul 10 11:32:20 2015] [error] for obj in self.query.objs
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/fields/files.py", line 252, in pre_save
[Fri Jul 10 11:32:20 2015] [error] file.save(file.name, file, save=False)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/fields/multistorage_file.py", line 95, in save
[Fri Jul 10 11:32:20 2015] [error] super(MultiStorageFieldFile, self).save(name, content, save)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/easy_thumbnails/files.py", line 667, in save
[Fri Jul 10 11:32:20 2015] [error] super(ThumbnailerFieldFile, self).save(name, content, *args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/fields/files.py", line 86, in save
[Fri Jul 10 11:32:20 2015] [error] self.name = self.storage.save(name, content)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/core/files/storage.py", line 49, in save
[Fri Jul 10 11:32:20 2015] [error] name = self._save(name, content)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/core/files/storage.py", line 172, in _save
[Fri Jul 10 11:32:20 2015] [error] os.makedirs(directory)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib64/python2.6/os.py", line 150, in makedirs
[Fri Jul 10 11:32:20 2015] [error] makedirs(head, mode)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib64/python2.6/os.py", line 150, in makedirs
[Fri Jul 10 11:32:20 2015] [error] makedirs(head, mode)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib64/python2.6/os.py", line 157, in makedirs
[Fri Jul 10 11:32:20 2015] [error] mkdir(name, mode)
[Fri Jul 10 11:32:20 2015] [error] OSError: [Errno 13] Permission denied: '/home/uronline/media/filer_public/3b'
我已经查看了很多其他提到这个问题的问题,这里是我检查过的内容:
httpd.conf
<VirtualHost *:80>
Alias /media/ /home/uronline/media/
<Directory /home/uronline/media>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
settings.py
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'
我用的是Apache,用户是apache
'media' 文件夹路径中的所有文件夹都设置为 755,用户:apache,组:www
出于好奇,我暂时将文件夹权限更改为777,但仍然出现错误。
我正在使用 django-filer 的默认设置,我现在想知道这个权限错误是否由此引起?
如有任何帮助,我们将不胜感激。谢谢。
好的,我明白了!一如既往,我的问题是 SELinux
原来 selinux 有一个布尔值 "Allows httpd daemon to write files in directories labeled public_content_rw_t" - 来自 http://wiki.centos.org/TipsAndTricks/SelinuxBooleans
所以这有效:
setsebool -P allow_httpd_anon_write on
希望这对某人有所帮助!
我安装了 django-filer,现在正在测试上传功能,但是当我尝试上传文件时,出现以下错误:
[Fri Jul 10 11:32:20 2015] [error] ERROR Internal Server Error: /admin/filer/clipboard/operations/upload/
[Fri Jul 10 11:32:20 2015] [error] Traceback (most recent call last):
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 112, in get_response
[Fri Jul 10 11:32:20 2015] [error] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
[Fri Jul 10 11:32:20 2015] [error] return view_func(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/admin/clipboardadmin.py", line 81, in ajax_upload
[Fri Jul 10 11:32:20 2015] [error] file_obj.save()
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/models/imagemodels.py", line 56, in save
[Fri Jul 10 11:32:20 2015] [error] super(Image, self).save(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/models/abstract.py", line 65, in save
[Fri Jul 10 11:32:20 2015] [error] super(BaseImage, self).save(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/models/filemodels.py", line 165, in save
[Fri Jul 10 11:32:20 2015] [error] super(File, self).save(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/polymorphic/polymorphic_model.py", line 89, in save
[Fri Jul 10 11:32:20 2015] [error] return super(PolymorphicModel, self).save(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 545, in save
[Fri Jul 10 11:32:20 2015] [error] force_update=force_update, update_fields=update_fields)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 572, in save_base
[Fri Jul 10 11:32:20 2015] [error] self._save_parents(cls, using, update_fields)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 597, in _save_parents
[Fri Jul 10 11:32:20 2015] [error] self._save_table(cls=parent, using=using, update_fields=update_fields)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 654, in _save_table
[Fri Jul 10 11:32:20 2015] [error] result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 687, in _do_insert
[Fri Jul 10 11:32:20 2015] [error] using=using, raw=raw)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 232, in _insert
[Fri Jul 10 11:32:20 2015] [error] return insert_query(self.model, objs, fields, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 1514, in insert_query
[Fri Jul 10 11:32:20 2015] [error] return query.get_compiler(using=using).execute_sql(return_id)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 902, in execute_sql
[Fri Jul 10 11:32:20 2015] [error] for sql, params in self.as_sql():
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 860, in as_sql
[Fri Jul 10 11:32:20 2015] [error] for obj in self.query.objs
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/fields/files.py", line 252, in pre_save
[Fri Jul 10 11:32:20 2015] [error] file.save(file.name, file, save=False)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/fields/multistorage_file.py", line 95, in save
[Fri Jul 10 11:32:20 2015] [error] super(MultiStorageFieldFile, self).save(name, content, save)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/easy_thumbnails/files.py", line 667, in save
[Fri Jul 10 11:32:20 2015] [error] super(ThumbnailerFieldFile, self).save(name, content, *args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/fields/files.py", line 86, in save
[Fri Jul 10 11:32:20 2015] [error] self.name = self.storage.save(name, content)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/core/files/storage.py", line 49, in save
[Fri Jul 10 11:32:20 2015] [error] name = self._save(name, content)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/core/files/storage.py", line 172, in _save
[Fri Jul 10 11:32:20 2015] [error] os.makedirs(directory)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib64/python2.6/os.py", line 150, in makedirs
[Fri Jul 10 11:32:20 2015] [error] makedirs(head, mode)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib64/python2.6/os.py", line 150, in makedirs
[Fri Jul 10 11:32:20 2015] [error] makedirs(head, mode)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib64/python2.6/os.py", line 157, in makedirs
[Fri Jul 10 11:32:20 2015] [error] mkdir(name, mode)
[Fri Jul 10 11:32:20 2015] [error] OSError: [Errno 13] Permission denied: '/home/uronline/media/filer_public/3b'
我已经查看了很多其他提到这个问题的问题,这里是我检查过的内容:
httpd.conf
<VirtualHost *:80>
Alias /media/ /home/uronline/media/
<Directory /home/uronline/media>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
settings.py
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'
我用的是Apache,用户是apache
'media' 文件夹路径中的所有文件夹都设置为 755,用户:apache,组:www
出于好奇,我暂时将文件夹权限更改为777,但仍然出现错误。
我正在使用 django-filer 的默认设置,我现在想知道这个权限错误是否由此引起?
如有任何帮助,我们将不胜感激。谢谢。
好的,我明白了!一如既往,我的问题是 SELinux
原来 selinux 有一个布尔值 "Allows httpd daemon to write files in directories labeled public_content_rw_t" - 来自 http://wiki.centos.org/TipsAndTricks/SelinuxBooleans
所以这有效:
setsebool -P allow_httpd_anon_write on
希望这对某人有所帮助!