我真的花了我所有的一天设置我的Django应用程序运行在我的BlueHost共享主机上。我的.htaccess
和mysite.fcgi
文件位于域根目录中,而不是帐户根目录,这意味着我有一个指向public_html/mysite
目录的网站MySite.com,因此上述两个文件位于public_html/mysite
文件夹下。Django共享主机设置
的.htaccess
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /mysite/mysite.fcgi/$1 [NC,L,QSA]
mysite.fcgi
#!/home1/username/myvirtualenv/bin/python
import sys, os
# Add a custom Python path.
sys.path.insert(0, "/home1/username/myvirtualenv/bin/python")
sys.path.insert(13, "/home1/username/www/mysite")
open("/home1/username/public_html/mysite/cgi.log", "w").write("Before try")
try:
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings.dev'
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
except Exception:
open("/home1/username/public_html/mysite/cgi.log", "w").write(format_exc())
raise
,当我通过ssh运行./mysite.fgci:
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 200 OK
X-Frame-Options: SAMEORIGIN
Content-Type: text/html; charset=utf-8
HTML here
,当我访问mysite.com在浏览器:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
任何帮助,高度赞赏!