Django Hosting on a FastCGI Shared Host

I am trying to set up django for shared hosting on iPage.com using FastCGI, but I am running into a problem all the time. CGI script is placed in the browser as text instead of execution. Below is the .htaccess and fcgi script

.htacess

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

and below - 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?

+3
source share
3 answers

Did you include execute permissions for the file? In your FTP client, enable the “execute” bit for user / group / others. Otherwise, apache will think that you just need to maintain the file.

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

+1
source

FastCGI, CGI. FastCGI - CGI, .

0

Javier is right, it won’t work. The documentation on how to deploy with FastCGI is here - you need to install flup and then start the FastCGI server inside Django.

0
source

Source: https://habr.com/ru/post/1756688/


All Articles