简体   繁体   English

在共享的FastCGI主机上托管Django

[英]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. 我正在尝试使用FastCGI在iPage.com上设置django共享主机,但我一直遇到问题。 The CGI script lods in the browser as text instead of executing. CGI脚本在浏览器中作为文本而不是执行。 Below is the .htaccess and the fcgi script 下面是.htaccess和fcgi脚本

.htacess .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 以下是fcgi脚本

#!/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. 在FTP客户端中,为用户/组/其他人启用“执行”位。 Otherwise apache will think it just needs to serve the file instead. 否则apache会认为它只需要提供文件。

If you have Linux shell access, you can also do chmod +x mysite.fcgi . 如果你有Linux shell访问权限,你也可以做chmod +x mysite.fcgi

you say FastCGI, but you're using CGI methods. 你说FastCGI,但你使用的是CGI方法。 FastCGI isn't a faster CGI implementation, they're two totally different things. FastCGI不是一个更快的CGI实现,它们是两个完全不同的东西。

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. 有关如何使用FastCGI进行部署的文档在这里 - 您需要安装flup然后在Django中运行FastCGI服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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