Welcome Guest | Login

dispatch.fcgi file shows as plain text

My dispatch.fcgi file is displaying the plain text contents of the file rather than running it. It's permission is set to 755.

I am attempting to get Django running without luck. It is to be setup in a subdomain rather than my public_html directory since I am just testing it out at the moment. I've tried putting all of the fcgi and py files in various locations since nothing has been functional.

My directory structure currently looks like this:
/home/username/django_projects/myproject
   manage.py
   settings.py
   urls.py
   __init__.py
/home/username/django_src
/home/username/public_html/django
   .htaccess
   dispatch.fcgi
   fcgi.py
   hello.fcgi
   django_templates/
   media/


This is what is in my dispatch.fcgi file:
#!/usr/bin/python2
import sys, os
sys.path += ['/home/username/django_src']
sys.path += ['/home/username/django_projects']
from fcgi import WSGIServer
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
from django.core.handlers.wsgi import WSGIHandler
WSGIServer(WSGIHandler()).run()

This is the .htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^(media/.*)$ - [L]
RewriteCond %{REQUEST_URI} !(dispatch.fcgi)
RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L]


I have successfully imported the django tables into mysql. The myproject settings file has the proper db connection information. I am not getting any error messages in my cPanel error log so that is why it has gotten difficult to debug.

At one point I had the debug feature of Django working but it would tell me something about ^admin/ not being found yet I had added that darn thing all over the place and it was uncommented in the urls.py file and I added 'django.contrib.admin', to the installed apps portion of the settings.py file. I do not know why it stopped showing the debug and started showing the plain text of dispatch.fcgi.

Thank you,
Sherri

2008-08-16 03:24 PM

It seems like the contents of your dispatch.fcgi and .htaccess files are incorrect. I am pasting the correct entries of these files below.

dispatch.fcgi
===
#!/usr/bin/env python
import sys
sys.path += ['/home/cPanelusername/django_src']
sys.path += ['/home/cPanelusrname/django_projects']
from fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'yourproject.settings'
WSGIServer(WSGIHandler()).run()
===

.htaccess
===
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L]
===

Could you please verify it by making the above said modifications.

2008-08-16 05:31 PM

HostingRails Support
Ok I made the modifications you listed above and also removed the fcgi apache handler I had added at one point to try to get it working. I had to do both to get the success page.

Thank you for your help. I've been attempting to get this darn thing working for weeks. I did have the dispatch.fcgi file exactly as you had above at one point but the htaccess file had your line 2 different. I think this line was the key solution to all of my troubles:
RewriteCond %{REQUEST_FILENAME} !-f

I think I'll make up a wiki page for getting it working on hosting rails. I followed one in a forum for bluehost which was helpful but not quite perfect it seems (terrible host of which I'm an ex-customer).

Sherri

2008-08-16 10:11 PM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!