views:

37

answers:

3

Hi, I'm using FastCGI to serve my Django app, so basically it works like this: http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache

What is the best way I can serve static media (images, css, etc) from this? Thanks!

A: 

Add any appropriate Alias directives to your web server configuration, from deepest to shallowest.

Ignacio Vazquez-Abrams
any links or eg?
nubela
http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias `Alias /media/app1 /srv/web123/app1/media` `Alias /media/app2 /srv/web123/app2/media` `Alias /media /srv/web123/project/media`
Ignacio Vazquez-Abrams
+1  A: 

If using Apache to front the site we normally go with WSGI for connecting to django and then let Apache handle '/media/...anything...' as statically served content. It's a couple lines of config and Bob's your Uncle!

Update: I should add that most of our Django sites are on dedicated servers, but you also can do this easily at webfaction.com.

E.g.

<Location "/media">
    SetHandler None
</Location>
Peter Rowell
Nice video tutorial from webfaction if you are using them: http://docs.webfaction.com/software/django/getting-started.html
Chris Lawlor
Good point. Webfaction has some of the best you're-not-an-idiot docs I've seen for a shared hosting solution.
Peter Rowell
A: 

I use this in my apache conf:

Alias /static/  /path/to/static/files/
<Directory /path/to/static/files/>
    Order deny,allow
    Allow from all
</Directory>
sdolan