Django Static File Hosting an Apache

I'm trying to move a Django site I have been working on out of the dev server stage and into a real hosting environment. For the time being, I'm just hosting on my personal machine. I already have Apache and mod-wsgi installed, but I'm having issues getting static files up. I'm pretty sure it has to do with Apache. Here is my config file for the site:

<VirtualHost *:80>

    ServerName localhost

    DocumentRoot /home/daifotis/code/

    Alias /media/ /home/daifotis/code/feris/sitestatic
    Alias /static/ /home/daifotis/code/feris/sitestatic
    #AliasMatch ^/([^/]*\.css) /home/daifotis/code/feris/sitestatic/$1

    <Directory /home/daifotis/code/feris/sitestatic>
        Order allow,deny
        Allow from all

    <Directory /home/daifotis/code/feris>
        Order allow,deny
        Allow from all

    <Directory /home/daifotis/code/feris/jobsite>
        Order allow,deny
        Allow from all

    WSGIDaemonProcess feris processes=2 threads=15 display-name=%{GROUP}
    WSGIProcessGroup feris

    WSGIScriptAlias / /home/daifotis/code/feris/apache/django.wsgi

    <Directory /home/daifotis/code/feris/apache>
        Order allow,deny
        Allow from all


I'm trying to host the files from the directory I alias with static. When I try to load the site, all the content comes up but no css. Also, when I hit my url, the page displays with the proper content of the directory. What I don't understand though, is why if I click on a link to view a file, it says that URL does not exist. I've been stuck on this for awhile so any help would be much appreciated.


Figured it out. I had an apache config error on this line:

Alias /static/ /home/daifotis/code/feris/sitestatic

I should have written static without the trailing slash. With the trailing slash Apache will not expand the URL path.

Alias /static /home/daifotis/code/feris/sitestatic

I'm assuming you're using Django 1.3, and the 'new' way of serving static files. Could you please show us the settings in your file relating to MEDIA and STATIC? Both the ROOT AND URL versions. Also show your STATICFILES_DIRS.

The most likely cause is that Django is only configured to serve static files with contrib.staticfiles. It's possible that you'll need to run the management command python collectstatic to collect all your application static files into a directory ready to be served by apache.

See my answer here regarding settings for using django.contrib.staticfiles.

If your static files exist, 100%, at the directory pointed to by Alias /static/ /home/daifotis/code/feris/sitestatic, then your permissions for apache are probably configured incorrectly. Have you checked the /var/log/httpd/error_log file to see if there is an IOPermissions error when trying to serve the static content?

Need Your Help

How to handle java variable length arguments in clojure?

clojure variadic-functions clojure-java-interop

I'am wrapping a java lib into clojure, but i have problems dealing with variable length arguments. Say,

Custom cursor in WPF?

.net wpf image cursor

I want to use an image or icon as a custom cursor in WPF app. What's the best way to do it?