4
votes

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()
3
And what does the error log say? - Cat Plus Plus
[Sun Nov 08 11:52:42 2009] [warn] FastCGI: (dynamic) server "/home/thegamer/public_html/dispatch.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 600 seconds - Peter Horne
What happens if you try to run dispatch.fcgi manually? If it works, it should just wait for for requests. If it terminates, it's probably with a message explaining what went wrong. - Rasmus Kaj
It output the expected HTML code. I have solved the problem but unfortunately am not entirely sure what was causing the problem. I'll try and find out and update when I have. Thanks for your help. - Peter Horne

3 Answers

1
votes

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.

1
votes

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

1
votes

I just had this exact same problem. It took some time but I was finally able to resolve it with assistance from A Small Orange’s (very helpful!) support guys.

You need to make sure that your dispatch.fcgi file is chmod’ed to 755. Anything else (mine was 775) will cause this error.