我使用Django 1.8进行Apache + fastCGI
共享主机上的我的文件夹如下所示:
/home/username/
/home/username/MyProject_SRC
/home/username/MyProject_SRC/MyProject/manage.py
和
/home/username/public_html/.htaccess
/home/username/public_html/index.fcgi
我已将.htaccess
和index.fcgi
编辑为:
.htaccess:
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/index.fcgi
RewriteRule ^(.*)$ index.fcgi/$1 [QSA,L]
index.fcgi:
#!/home/username/djangoenv/bin/python3
import sys, os
sys.path.insert(0, "/home/username/MyProject_SRC")
os.chdir("/home/username/MyProject_SRC")
os.environ['DJANGO_SETTINGS_MODULE'] = "MyProject.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
现在,当我在服务器上时:
(djangoenv)username@hostname [~/public_html]# ./index.fcgi
Status: 200 OK
Vary: Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
<html lang="en">
.... // Normal webpage
</html>
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!
在我的主页上返回500 internal error
,不再包含日志。
编辑我做的时候得到了相同的结果:
(djangoenv)username@hostname [~/MyProject_SRC]# ./manage.py runfcgi
答案 0 :(得分:0)
我遇到了类似的问题,在我的情况下,我没有找到特定的来源,但是我尝试将其添加到我的 index.fcgi 中,并且不再要求./index.fcgi,如果它持续显示500,请检查您使用的 flup 的版本,最好是 1.0.2 。
os.environ['REQUEST_METHOD'] = "GET"
os.environ['SERVER_NAME'] = "yourdomain.com"
os.environ['SERVER_PORT'] = "80"
os.environ['SERVER_PROTOCOL'] = "HTTP/1.1"