apache fastCGi with Django:“missing FastCGI param required by WSGI!”

qv7cva1a  于 2023-11-21  发布在  Apache
关注(0)|答案(2)|浏览(182)

Apache + fastCGI + Django 1.8
我在共享主机上的文件夹看起来像:
第一个月
/home/username/MyProject_SRC
/home/username/MyProject_SRC/MyProject/manage.py
以及:
/home/username/public_html/.htaccess
/home/username/public_html/index.fcgi
我编辑了.htaccessindex.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

yduiuuwa

yduiuuwa1#

我有一个类似的问题,在我的情况下,我没有找到一个特定的源,但我试图在我的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"

字符串

7qhs6swi

7qhs6swi2#

当我得到这个错误时,问题原来是服务器更改已经删除了我所有自定义安装的python包,包括flup。所以修复只是安装它:

pip3 install flup

字符串

相关问题