質問

まず、スクリプトを次に示します:

#!/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によって自動的に渡されないのですか?何が間違っていますか? Webサーバーからスクリプトを実行すると、サーバー内部エラーが発生します。


スクリプトの最後の2行の代わりに、次を使用できます

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 、および< a href = "http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/" rel = "nofollow noreferrer"> Djangoのドキュメント。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top