Python 禁止访问django apache2媒体文件

Python 禁止访问django apache2媒体文件,python,django,apache,media,Python,Django,Apache,Media,我无法从django管理站点访问我的文件。我保存文件没有任何问题,但当我尝试打开它时,我得到错误: Forbidden You don't have permission to access /media/file.pdf on this server. 在django项目设置中: STATIC_URL = '/static/' STATIC_ROOT = '/full/path/to/static/' MEDIA_URL = '/media/' MEDIA_ROOT = os.path.

我无法从django管理站点访问我的文件。我保存文件没有任何问题,但当我尝试打开它时,我得到错误:

Forbidden
You don't have permission to access /media/file.pdf on this server.
在django项目设置中:

STATIC_URL = '/static/'

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

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
 Alias /static/ "/static/folder/"
 Alias /media/ "/meida/folder/" 
 <Directory "/static/folder">
    Require all granted
 </Directory>
 <Directory "/media/folder">
    Require all granted
 </Directory>
<Directory /usr/local/django_apps/myapp/static>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
在project url.py中:

if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
在我的虚拟主机中,我添加了以下设置:

STATIC_URL = '/static/'

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

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
 Alias /static/ "/static/folder/"
 Alias /media/ "/meida/folder/" 
 <Directory "/static/folder">
    Require all granted
 </Directory>
 <Directory "/media/folder">
    Require all granted
 </Directory>
<Directory /usr/local/django_apps/myapp/static>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

更改/etc/apache2/conf/php5-fpm.conf。更换每个

Order Deny,Allow
Deny from all

必须通过
a2enconf php5 fpm
启用配置

编辑

遵循基本配置:

编辑2

进行更改并将其添加到virtualhost设置中:

STATIC_URL = '/static/'

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

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
 Alias /static/ "/static/folder/"
 Alias /media/ "/meida/folder/" 
 <Directory "/static/folder">
    Require all granted
 </Directory>
 <Directory "/media/folder">
    Require all granted
 </Directory>
<Directory /usr/local/django_apps/myapp/static>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

选项索引跟随符号链接
不允许超限
要求所有授权

请注意,路径是从根开始的

但这是django(python)项目。在我的/etc/apache2/conf available/folder php5-fpm.conf中不存在。我不知道为什么当我尝试访问媒体文件时会出现403错误,但静态文件夹都正常。在媒体目录上尝试了此设置,但将其添加到静态,可能会有所帮助。try
sudo chown-R www-data/path/to/media/
@itzmeontv-Done。还是一样的错误。