我真的花了我所有的一天設置我的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.
任何幫助,高度讚賞!