Django WSGI Apache VirtualHost, returning a 404 Error

Viewed 4063
  • Ubuntu 12.04
  • Apache 2.2.2
  • Python 3.2.3
  • Django 1.6.1

I followed directions at Using mod_wsgi to Serve Applications on Ubuntu 12.04, for setting up a WSGI for my Django on Apache. Problem is, the VirtualHost domain is now returning a confusingly weird 404 error:

[Mon Dec 16 19:53:49 2013] [error] [client 127.0.0.1] File does not exist: /etc/apache2/htdocs

It's confusing because... that directory doesn't even exist. The VirtualHost is setup in /var/www/main and the config's for it in /var/apache2/sites-available/default looks like this:

<VirtualHost *:80>
        ServerName 127.0.0.1
        ServerAlias coral
        WSGIScriptAlias / /home/dfy/code/djdev/djdev/wsgi.py
</VirtualHost>

I reloaded Apache after editing. That wsgi file is the one generated by Django when I started the project. I altered it to match what was needed according to the tutorial:

import os
import sys # added from tutorial
sys.path.append('/home/dfy/code/djdev/djdev/') # added from tutorial
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djdev.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

To me, this all looks like it should work, but Apache is lookin' for static files in a non-existent directory (/etc/apache2/htdocs). I've been Googling for hours trying to figure out what's wrong here, but haven't found the answer. On a whim I tried chmod 777 wsgi.py, but that didn't change anything, so I'm sure it's not a permissions problem. I really no idea what's gone wrong.

2 Answers
Related