我已经安装了apache和mod_wsgi,并且检索并显示了所有网页,但是当我尝试访问静态文件时,没有加载静态文件(如css)(例如:http:// localhost / static / css /base.css)它说我没有访问该文件的权限,同样适用于媒体文件。所以基本上返回的网页只是纯HTML。
我已按照演示幻灯片http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-pycon-sydney-2010.pdf中的步骤操作,并通过chmod o+rx /home/loai/workspace/Faculty
让其他人可以访问这些目录
,我的httpd.conf部分是:
WSGIScriptAlias / /home/loai/workspace/Faculty/Faculty/wsgi.py
WSGIPythonPath /home/loai/workspace/Faculty
Alias /media/ /home/loai/workspace/Faculty/Faculty/media
Alias /static/ /home/loai/workspace/Faculty/Faculty/static
<Directory /home/loai/workspace/Faculty/Faculty/static>
Order deny,allow
Allow from all
</Directory>
<Directory /home/loai/workspace/Faculty/Faculty/media>
Order deny,allow
Allow from all
</Directory>
<Directory /home/loai/workspace/Faculty/Faculty>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
奇怪的是,当我删除“Files”指令时,它变为:
<Directory /home/loai/workspace/Faculty/Faculty>
Order deny,allow
Allow from all
</Directory>
instead of
<Directory /home/loai/workspace/Faculty/Faculty>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
然后尝试访问任何静态或媒体文件引发(未找到)而不是拒绝权限!但仍然加载了纯html页面!
答案 0 :(得分:2)
而不是:
Alias /media/ /home/loai/workspace/Faculty/Faculty/media
Alias /static/ /home/loai/workspace/Faculty/Faculty/static
使用:
Alias /media/ /home/loai/workspace/Faculty/Faculty/media/
Alias /static/ /home/loai/workspace/Faculty/Faculty/static/
如果在挂载点上有尾部斜杠,则需要在目录上使用尾部斜杠。如果你没有匹配,可能无法正常工作。
答案 1 :(得分:0)
试试这个..如果尝试添加媒体目录的配置。确保以递归方式设置静态文件夹的读取权限
<VirtualHost *:80>
DocumentRoot /home/loai/workspace/Faculty/
Alias /static/ /home/loai/workspace/Faculty/static/
<Directory /home/loai/workspace/Faculty>
Order allow,deny
Allow from all
</Directory>
<Location "/static/">
SetHandler None
</Location>
WSGIScriptAlias / /home/loai/workspace/Faculty/Faculty/wsgi.py
</VirtualHost>
更新
我建议在教师应用程序之外复制静态文件夹。我已经更改了配置文件中的路径。