简体   繁体   中英

Hosting Django on a shared FastCGI host

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?

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 .

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM