I've searched a lot but I still have a problem with the static files (css, image,...) with my django website.
I'm using mod_wsgi with apache on archlinux 64bits
I've added it in my 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>
I tried to use the django.wsgi in my home folder but it doesn't work (permission denied to access /
) (strangely it works if I use the test script given here)
all the directories and content (apache folder, wsgi-script, martfiles) have the permission 775 root:devusers
with the group devusers including my user, http and root
in my template base.html, I call the css this way :
<html> <head>
<link rel="stylesheet" href="/media/css/style.css" />
and the error in /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 ''
/etc/httpd/conf/http.conf
/srv/http/wsgi-script/django.wsgi
/home/.../martfiles/settings.py
thank you
edit : I precise that my django website is working fine (except the sessions but I don't think it's related) so I'm not sure it's related to the django.wsgi file (maybe I'm wrong) but what is sure is that I should be able to use the django.wsgi from outside the apache folder
if I change the line Alias /media /home/mart/programmation/python/django/martfiles/media/
with Alias /media /srv/http/media/
and gives the right permissions, it works. But I don't want (and shouldn't) to put all my media in the apache folder
It is not sufficient for just the directory '/home/mart/programmation/python/django/martfiles/media' containing static files to be readable and searchable. The user that Apache runs as must have read and potentially search access, to all parent directories of it back up to root directory. Since home directories on many systems are 'rwx------' this would deny Apache access irrespective of the Deny/Allow directives in Apache configuration.
Suggest you place the Django project and static files outside of your home account somewhere and relax the file system permissions as necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With