N
N
Nikolai Vinogradov2017-02-02 13:41:53
Django
Nikolai Vinogradov, 2017-02-02 13:41:53

Forbidden access for django apache2 media files, what's the problem?

There is a jungi admin panel running on ubuntu via apache with mod_wsgi. You can save files in the admin panel, and they are saved without problems. But when I try to open the saved file I get:


Forbidden
You don't have permission to access /media/file.pdf on this server.

In settings.py I have:
STATIC_URL = '/static/'

STATIC_ROOT = '/full/path/to/static/'

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

In URLs.py:
if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

In Apache:
Alias /static/ "/static/folder/"
 Alias /media/ "/meida/folder/" 
 <Directory "/static/folder">
    Require all granted
 </Directory>
 <Directory "/media/folder">
    Require all granted
 </Directory>

The same message is written to error.log all the time:
client denied by server configuration: /etc/apache2/home

What could be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
taliano, 2017-02-02
@taliano

How about adding to the Directory section

Order allow,deny
Allow from all

?
Well, it would be nice to show /etc/apache2/home in full.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question