views:

544

answers:

2

Solved: Unfortunately I wasn't able to solve the problem but I started over and followed the Django + FastCGI guide on the "A Small Orange" wiki and everything is working as expected.

I am trying to setup Django with FCGI on Apache. The web hosting plan that I am using is A Small Orange's shared hosting plan.

Django is installed, working and is able to create database tables when I run the syncdb command. If I run manage.py runserver and then use lynx to navigate to localhost:8080 django will correctly display. However, It is not possible to view django over the internet as the page displays a 500 internal server error.

I have the flup python package installed and am using python version 2.6.

The following is the contents of my .htaccess file that is situated in /public_html/:

RewriteEngine On
  RewriteBase /
  RewriteRule ^(media/.*)$ - [L]
  RewriteRule ^(admin_media/.*)$ - [L]
  RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
  RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]

The following is the contents of my dispatch.fcgi file that is also located in /public_html:

#!/usr/local/lib/python2.6
import sys
import os
os.chdir('/home/thegamer/django/projects/thegamer')
sys.path += ['/home/thegamer/django/django']
sys.path += ['/home/thegamer/django/projects']
from fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'thegamer.settings'
WSGIServer(WSGIHandler()).run()
A: 

Are you using sqlite? If so, you need an absolute path for the db file, not a relative.

If thats not it, set DEBUG=True in your settings and let django tell you what it is.

Rasmus Kaj
I am using mysql and the problem isn't with my database. The problem occurs somewhere between apache recieving the request and it being passed to django to handle. Running django locally works fine so no errors are produced. Running it over the internet causes problems and I cannot access it to view what the error messages would be.
Pheter
As an alternative, it is possible to use email notification for getting the debug infos see http://stackoverflow.com/questions/1648349/common-errors-when-moving-a-django-app-from-dev-to-prod/1648578#1648578
luc
It's more probably some environmental difference between you running the manage command and apache running the server than an error before reaching django (or if the error is before django, there is probably something usefull in the default error log of apache). So enable debugging (or email-on-error, but then you also need to make sure that mail from the server can actually reach you) and check the error message.
Rasmus Kaj
(Ignore previous message, didn't see your quote of the actual error message above)
Rasmus Kaj
A: 

Starting again and following the Django + FastCGI guide on the "A Small Orange" wiki resulted in everything working as expected.

Pheter