Django on Apache with FCGI
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()
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.
Starting again and following the Django + FastCGI guide on the "A Small Orange" wiki resulted in everything working as expected.
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.
精彩评论