![](/img/trans.png)
[英]Cannot access file in current working directory - 'FileNotFoundError: [Errno 2] No such file or directory'
[英]Apache cannot access the directory that is included in the conf file
我的django
应用程序中有一个名为media
的目录。 我已经在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禁止错误。
编辑:
Apache可以在/static/
目录中找到文件,但不能在/media/
目录中找到文件!
根据我们的讨论,我们消除了一些可能性,但是仍然值得仔细检查配置文件中的输入错误(例如,路径区分大小写)。 很多人经常被这个容易错过的细节所困扰。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.