Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带Django的fastCGi:“;缺少WSGI所需的FastCGI参数请求_方法&引用;_Django_Apache_Fastcgi - Fatal编程技术网

带Django的fastCGi:“;缺少WSGI所需的FastCGI参数请求_方法&引用;

带Django的fastCGi:“;缺少WSGI所需的FastCGI参数请求_方法&引用;,django,apache,fastcgi,Django,Apache,Fastcgi,我使用的是Apache+fastCGI和Django 1.8 共享主机上的我的文件夹如下所示: /home/username/ /home/username/MyProject\u SRC /home/username/MyProject\u SRC/MyProject/manage.py 以及: /home/username/public\u html/.htaccess /home/username/public\u html/index.fcgi 我编辑了.htaccess和index.f

我使用的是Apache+fastCGI和Django 1.8

共享主机上的我的文件夹如下所示:

/home/username/

/home/username/MyProject\u SRC

/home/username/MyProject\u SRC/MyProject/manage.py

以及:

/home/username/public\u html/.htaccess

/home/username/public\u html/index.fcgi

我编辑了
.htaccess
index.fcgi
如下:

.htaccess:

AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/index.fcgi
RewriteRule ^(.*)$ index.fcgi/$1 [QSA,L]
#!/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")
index.fcgi:

AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/index.fcgi
RewriteRule ^(.*)$ index.fcgi/$1 [QSA,L]
#!/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!
(djangoenv)username@hostname[~/public_html]./index.fcgi
状态:200 OK
变化:饼干
X-Frame-Options:SAMEORIGIN
内容类型:text/html;字符集=utf-8
.... // 普通网页
WSGIServer:缺少WSGI所需的FastCGI参数请求_方法!
WSGIServer:缺少WSGI所需的FastCGI参数服务器名称!
WSGIServer:缺少WSGI所需的FastCGI参数服务器\u端口!
WSGIServer:缺少WSGI所需的FastCGI param SERVER_协议!
进入我的主页返回
500内部错误
,日志中没有更多错误

编辑我在执行以下操作时得到了相同的结果:
(djangoenv)username@hostname[~/MyProject\u SRC]./manage.py runfcgi

我也遇到了类似的问题,在我的例子中,我没有找到具体的来源,但我尝试将其添加到我的index.fcgi中,而doing./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"

我不明白在shell中运行index.fcgi希望实现什么。当您请求一个页面时,它应该由Apache调用。好的,我已经使用
/manage.py runfcgi
进行了编辑。基本上,我只是想知道问题出在哪里,因为我只有500个内部错误,没有任何错误。是否还有另一个测试来了解fastCGI是否能正确使用我的Django配置?