문제

먼저 여기 내 대본이 있습니다.

#!/usr/bin/python
import sys, os

sys.path.append('/home/username/python')
sys.path.append("/home/username/python/flup")
sys.path.append("/home/username/python/django")
# more path stuff

os.environ['DJANGO_SETTINGS_MODULE'] = "project.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

설명 된 바와 같이 여기.

그리고 다음은 쉘에서 실행하려고 할 때 얻는 오류입니다.

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: 404 NOT FOUND
Content-Type: text/html


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<!-- more html which looks to be the correct output -->

내 질문은 왜 그 매개 변수가 FastCGI에 의해 자동으로 전달되지 않습니까? 내가 뭘 잘못하고 있죠? 내 웹 서버에서 스크립트를 실행하면 내부 서버 오류가 발생합니다.


내 스크립트의 마지막 두 줄 대신에

from flup.server.fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
WSGIServer(WSGIHandler()).run()

하지만 여전히 똑같은 오류가 발생합니다 ...

도움이 되었습니까?

해결책

그것을 해결했습니다. 이 .htaccess 파일은 어떤 이유로 든 트릭을 수행했습니다. 나는이 모든 것을 전에 시도했다고 맹세한다 ...

AddHandler fcgid-script .fcgi
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(adminmedia/.*)$ - [L]
RewriteCond %{REQUEST_URI} !(cgi-bin/myproject.fcgi)
RewriteRule ^(.*)$ cgi-bin/myproject.fcgi/$1 [L]

다른 팁

스크립트는 이러한 매개 변수가 환경 변수로 전달 될 것으로 기대합니다. 쉘 환경에는 존재하지 않으며 스크립트가 Apache FastCGI 환경에서 실행되지 않기 때문에 (이를 제공하는) 불평합니다.

Apache 오류 로그에 액세스 할 수 있습니까? 그들은 무엇을 말합니까?

호스트에 mod_wsgi 지원이 있습니까? 그렇다면 Django의 WSGI 핸들러를 사용할 수 있습니다.

import sys
import os

base = os.path.dirname(os.path.abspath(__file__)) + '/..'
sys.path.append(base)

os.environ['DJANGO_SETTINGS_MODULE'] = 'yourproject.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

추가 지침을 찾을 수 있습니다 Modwsgi Wiki, 그리고 장고 문서.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top