我搜索了很多,但我的 django 网站的静态文件(css、图像、...)仍然存在问题。
我在archlinux 64位上使用mod_wsgi和apache
我已将其添加到我的 http.conf 中:
LoadModule wsgi_module modules/mod_wsgi.so
<VirtualHost *:80>
WSGIDaemonProcess mart.localhost user=mart group=users processes=2 threads=25
WSGIProcessGroup mart.localhost
LogLevel debug
Alias /media /home/mart/programmation/python/django/martfiles/media/
<Directory /home/mart/programmation/python/django/martfiles/>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / /srv/http/wsgi-scripts/django.wsgi
</VirtualHost>
我尝试在我的主文件夹中使用 django.wsgi,但它不起作用(permission denied to access /
)(奇怪的是,如果我使用这里给出的测试脚本它会起作用)
所有目录和内容(apache 文件夹、wsgi-script、martfiles)都具有775 root:devusers
devusers 组的权限,包括我的用户、http 和 root
在我的模板 base.html 中,我以这种方式调用 css:
<html> <head>
<link rel="stylesheet" href="/media/css/style.css" />
和 /var/log/http/error.log 中的错误
[Sat Jan 16 13:22:21 2010] [error] [client 127.0.0.1] (13)Permission denied: access to /media/css/style.css denied, referer: http://localhost/
[Sat Jan 16 13:22:21 2010] [info] mod_wsgi (pid=14783): Attach interpreter ''
/srv/http/wsgi-script/django.wsgi
/home/.../martfiles/settings.py
谢谢你
编辑:我确切地说我的 django 网站运行良好(会话除外,但我认为它不相关)所以我不确定它是否与 django.wsgi 文件相关(也许我错了)但可以肯定的是我应该能够从 apache 文件夹外部使用 django.wsgi
如果我更改行Alias /media /home/mart/programmation/python/django/martfiles/media/
并Alias /media /srv/http/media/
提供正确的权限,它就可以工作。但我不想(也不应该)将我所有的媒体都放在 apache 文件夹中