Apache无法访问conf文件中包含的目录

时间:2015-10-17 10:14:28

标签: python django apache

我的media应用程序中有一个名为django的目录。我已经在我的apache conf文件中声明了该目录,并且该目录及其所有文件的权限是755.但是当我尝试从其加载图像时,url apache说:

Forbidden
You don't have permission to access /media/foo.jpg on this server.

这是我的apache conf文件:

<VirtualHost *:80>

Alias /static/ /root/websites/FJSharif/static/
<Directory /root/websites/FJSharif/static>
Order deny,allow
Allow from all
Require all granted
</Directory>

Alias /media/ /root/websites/FJSharif/media/
<Directory /root/websites/fJSharif/media>
Order deny,allow
Allow from all
Require all granted
</Directory>

<Directory /root/websites/FJSharif/FJSharif>
<Files wsgi.py>
Order deny,allow
Allow from all
Require all granted
</Files>
</Directory>
WSGIDaemonProcess FJSharif python-path=/root/websites/FJSharif:/home/user/myproject/myprojectenv/lib/python2.7/site-packages:/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages

WSGIProcessGroup FJSharif
WSGIScriptAlias / /root/websites/FJSharif/FJSharif/wsgi.py
</VirtualHost>

当我尝试加载此网址时:

http://example.com/media/foo.img

我收到403 Forbidden错误。

编辑:

Apache可以在/static/目录中找到文件,但不能找到/media/目录中的文件!

1 个答案:

答案 0 :(得分:1)

根据我们的讨论,我们消除了一些可能性,但仍然值得仔细检查配置文件中的拼写错误(例如路径区分大小写)。许多人经常被这个容易错过的细节所困扰。