views:

73

answers:

3

Hi, I am trying to set up django shared hosting at iPage.com using FastCGI but I keep running into issue. The CGI script lods in the browser as text instead of executing. Below is the .htaccess and the fcgi script

.htacess

AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ cgi-bin/mysite.fcgi/$1 [QSA,L]

and below is the fcgi script

#!/usr/bin/python
import sys, os

# Add a custom Python path.
sys.path.insert(0, "/home/users/web/b2374/ipg.navtejportfoliocom/django")

# Switch to the directory of your project. (Optional.)
os.chdir("/home/user/myproject")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "tej.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

What am I not doing right?

A: 

you say FastCGI, but you're using CGI methods. FastCGI isn't a faster CGI implementation, they're two totally different things.

Javier
the fcgi doesnt work on the root folder, so I decided to copy it to CGI. plus djangoproject recommends use of fcgi for django since cgi involves a call to python+django+content for every page loaded while fcgi eliminates the refetching
A: 

Javier is right, this won't work. The documentation on how to deploy with FastCGI is here - you need to install flup then run the FastCGI server inside Django.

Daniel Roseman
I think the example is perfectly fine: http://docs.djangoproject.com/en/1.2/howto/deployment/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache
vdboor
I accepted the first answer by default. Turns out my host doesn't support FastCGI, WSGI and AJP.
A: 

Have you enabled execute permissions on the file? In your FTP client, enable the "execute" bit for user/group/others. Otherwise apache will think it just needs to serve the file instead.

If you have Linux shell access, you can also do chmod +x mysite.fcgi.

vdboor