skip to Main Content

I got error message when upload file into media folder.
I already have set everything to 777 permisson and change owner to apache.
Loading media and static files are fine.
I m using centos7 with httpd service.
Please, help me to figure it out.

For addition information, wirte file through hardcode is working fine.

The error looks like

Here’s the error message:

Traceback:

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
  552.                 return self.admin_site.admin_view(view)(*args, **kwargs)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
  224.             return view(request, *args, **kwargs)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/contrib/admin/options.py" in change_view
  1512.         return self.changeform_view(request, object_id, form_url, extra_context)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/contrib/admin/options.py" in changeform_view
  1409.             return self._changeform_view(request, object_id, form_url, extra_context)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/contrib/admin/options.py" in _changeform_view
  1449.                 self.save_model(request, new_object, form, not add)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/contrib/admin/options.py" in save_model
  980.         obj.save()

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/contrib/auth/base_user.py" in save
  80.         super(AbstractBaseUser, self).save(*args, **kwargs)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/db/models/base.py" in save
  808.                        force_update=force_update, update_fields=update_fields)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/db/models/base.py" in save_base
  838.             updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/db/models/base.py" in _save_table
  902.                       for f in non_pks]

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/db/models/fields/files.py" in pre_save
  296.             file.save(file.name, file.file, save=False)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/db/models/fields/files.py" in save
  94.         self.name = self.storage.save(name, content, max_length=self.field.max_length)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/core/files/storage.py" in save
  54.         return self._save(name, content)

File "/opt/ezadmin/env/lib/python2.7/site-packages/django/core/files/storage.py" in _save
  347.                     fd = os.open(full_path, flags, 0o666)

Exception Type: OSError at /ezadmin/user/1/change/
Exception Value: [Errno 13] Permission denied: '/opt/ezadmin/media/users/hqdefault.jpg'

2

Answers


  1. Chosen as BEST ANSWER

    U need to change permisson through SELinux

    chcon -Rv --type=httpd_sys_rw_content_t /var/html/myweb/uploads
    

  2. Ah the pitfalls of using apache after using the django development server…

    Things to check:

    1) Make sure your have set an alias to your MEDIA folder so that http://www.derf.com/media is routed correctly

     Alias /media/ /var/www/derf/media/
    

    2) Make sure that directory has approprate APACHE permissions. Apache does not blindly follow OS level permissions because people.

    <Directory /var/www/derf/media/
        Require all granted
    </Directory>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search