Setting up Django, Apache and mod_wsgi on Debian 6 (Squeeze)

Set up Django, Apache and mod_wsgi on Debian 6 (Squeeze), per this guide:

http://library.linode.com/frameworks/dj … -6-squeeze">http://library.linode.com/frameworks/django-apache-mod-wsgi/debian-6-squeeze

Keep getting "500 Internal Server Error"

And this is what error-log looks like:


[Thu Dec 20 03:32:11 2012] [error] [client 99.113.35.235] mod_wsgi (pid=5742): Exception occurred processing WSGI script '/srv/www/klkds.com/application/django.wsgi'.

[Thu Dec 20 03:32:11 2012] [error] [client 99.113.35.235] Traceback (most recent call last):

[Thu Dec 20 03:32:11 2012] [error] [client 99.113.35.235] File "/usr/local/lib/python2.6/dist-packages/Django-1.4.3-py2.6.egg/django/core/handlers/wsgi.py", line 219, in call

[Thu Dec 20 03:32:11 2012] [error] [client 99.113.35.235] self.load_middleware()

[Thu Dec 20 03:32:11 2012] [error] [client 99.113.35.235] File "/usr/local/lib/python2.6/dist-packages/Django-1.4.3-py2.6.egg/django/core/handlers/base.py", line 39, in load_middleware

[Thu Dec 20 03:32:11 2012] [error] [client 99.113.35.235] for middlewarepath in settings.MIDDLEWARECLASSES:

[Thu Dec 20 03:32:11 2012] [error] [client 99.113.35.235] File "/usr/local/lib/python2.6/dist-packages/Django-1.4.3-py2.6.egg/django/utils/functional.py", line 184, in inner

[Thu Dec 20 03:32:11 2012] [error] [client 99.113.35.235] self._setup()

[Thu Dec 20 03:32:11 2012] [error] [client 99.113.35.235] File "/usr/local/lib/python2.6/dist-packages/Django-1.4.3-py2.6.egg/django/conf/init.py", line 42, in _setup

[Thu Dec 20 03:32:11 2012] [error] [client 99.113.35.235] self.wrapped = Settings(settingsmodule)

[Thu Dec 20 03:32:11 2012] [error] [client 99.113.35.235] File "/usr/local/lib/python2.6/dist-packages/Django-1.4.3-py2.6.egg/django/conf/init.py", line 95, in init

[Thu Dec 20 03:32:11 2012] [error] [client 99.113.35.235] raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))

[Thu Dec 20 03:32:11 2012] [error] [client 99.113.35.235] ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named settings

–-

My Django application is in folder: /srv/www/klkds.com/application/

This is what django.wsgi file looks like (saved in: /srv/www/klkds.com/application/django.wsgi):


import os

import sys

sys.path.append('/srv/www/klkds.com/application')

sys.path.append('/srv/www/klkds.com/')

os.environ['PYTHONEGGCACHE'] = '/srv/www/klkds.com/.python-egg'

os.environ['DJANGOSETTINGSMODULE'] = 'settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

–-

Am I supposed to set the path for DJANGOSETTINGSMODULE to my settings.py file? It's located at: /srv/www/klkds.com/application/application/settings.py

Help much appreciated!

2 Replies

I keep the .wsgi file and the settings.py file in the same directory. Try moving the settings file to that location as a test.

James

if you use a command "django-admin.py startproject mysite"

it will create two nested folders mysite/mysite/ where settings.py file will be located.

do you leave your settings.py file in: mysite/mysite/settings.py and also put django.wsgi file there?

or, do you put your django.wsgi file in: my site/django.wsgi and then move the automatically generated settings.py file from mysite/mysite/settings.py to mysite/settings.py ?

thanks for the clarification

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct