2

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>

設定.py

MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'

私は Apache を使用しており、ユーザーは apache です

「メディア」フォルダーへのパス内のすべてのフォルダーは、ユーザー: apache、グループ: www で 755 に設定されています。

好奇心から、フォルダーのアクセス許可を一時的に 777 に変更しましたが、それでもエラーが発生しました。

私は django-filer のデフォルト設定を使用していますが、これが原因でこの権限エラーが発生したのでしょうか?

どんな助けでも大歓迎です。ありがとうございました。

4

1 に答える 1

0

わかりました、私はそれを理解しました!いつものように、私の問題はSELinuxにありました

selinuxには、「httpdデーモンがpublic_content_rw_tというラベルの付いたディレクトリにファイルを書き込むことを許可する」というブール値があることがわかりました-http ://wiki.centos.org/TipsAndTricks/SelinuxBooleansから

だからこれはうまくいった:

setsebool -P allow_httpd_anon_write on

これが誰かを助けることを願っています!

于 2015-07-10T21:17:51.950 に答える