我正在尝试使用以下说明在共享主机上安装Django: docs.google.com/View?docid=dhhpr5xs_463522g
我的问题是我的root .htaccess上的以下行:
RewriteRule ^(.*)$ /cgi-bin/wcgi.py/$1 [QSA,L]
当我加入此行时,我在此帐户中几乎所有域名都会收到500错误。
我的cgi-bin目录是home / my-username / public_html / cgi-bin /
wcgi.py文件包含:
#!/usr/local/bin/python
import os, sys
sys.path.insert(0, "/home/username/django/")
sys.path.insert(0, "/home/username/django/projects")
sys.path.insert(0, "/home/username/django/projects/newprojects")
import django.core.handlers.wsgi
os.chdir("/home/username/django/projects/newproject") # optional
os.environ['DJANGO_SETTINGS_MODULE'] = "newproject.settings"
def runcgi():
environ = dict(os.environ.items())
environ['wsgi.input'] = sys.stdin
environ['wsgi.errors'] = sys.stderr
environ['wsgi.version'] = (1,0)
environ['wsgi.multithread'] = False
environ['wsgi.multiprocess'] = True
environ['wsgi.run_once'] = True
application = django.core.handlers.wsgi.WSGIHandler()
if environ.get('HTTPS','off') in ('on','1'):
environ['wsgi.url_scheme'] = 'https'
else:
environ['wsgi.url_scheme'] = 'http'
headers_set = []
headers_sent = []
def write(data):
if not headers_set:
raise AssertionError("write() before start_response()")
elif not headers_sent:
# Before the first output, send the stored headers
status, response_headers = headers_sent[:] = headers_set
sys.stdout.write('Status: %s\r\n' % status)
for header in response_headers:
sys.stdout.write('%s: %s\r\n' % header)
sys.stdout.write('\r\n')
sys.stdout.write(data)
sys.stdout.flush()
def start_response(status,response_headers,exc_info=None):
if exc_info:
try:
if headers_sent:
# Re-raise original exception if headers sent
raise exc_info[0], exc_info[1], exc_info[2]
finally:
exc_info = None # avoid dangling circular ref
elif headers_set:
raise AssertionError("Headers already set!")
headers_set[:] = [status,response_headers]
return write
result = application(environ, start_response)
try:
for data in result:
if data: # don't send headers until body appears
write(data)
if not headers_sent:
write('') # send headers now if body was empty
finally:
if hasattr(result,'close'):
result.close()
runcgi()
只有我将“用户名”更改为我的用户名...
答案 0 :(得分:0)
看起来我应该在我的托管服务中使用fastcgi:
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.fcgi/$1 [QSA,L]