Ubuntuのapache2/mod_wsgiでCherryPyアプリを実行しようとしています。私はここで概説されているチュートリアルに従っています、そして私の設定はほとんど同じです。サイトのルートにアクセスすると、500内部サーバーエラーが発生します。ログの唯一のエラーは次のとおりです。
[Mon Dec 03 04:43:06 2012] [error] [client 64.189.251.239] Premature end of script headers: index.py
チュートリアルのいくつかのバリエーションを試しましたが、重大なエラーは発生していません。何か案は?
私のApache VirtualHost
:
...
WSGIScriptAlias / /var/www/example.com/uba/index.py
DocumentRoot /var/www/example.com/uba/
<Directory />
Options +ExecCGI Indexes FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/example.com/uba/>
Options +ExecCGI -Indexes -FollowSymLinks -MultiViews
WSGIApplicationGroup %{GLOBAL}
AllowOverride All
Order allow,deny
allow from all
</Directory>
...
私のindex.pyスクリプト:
#!/usr/bin/python
import sys
sys.stdout = sys.stderr
import atexit
import threading
import cherrypy
cherrypy.config.update({'environment': 'embedded'})
if cherrypy.__version__.startswith('3.0') and cherrypy.engine.state == 0:
cherrypy.engine.start(blocking=False)
atexit.register(cherrypy.engine.stop)
class Root(object):
def index(self):
return 'Hello World!'
index.exposed = True
application = cherrypy.Application(Root(), script_name=None, config=None)
更新#1:
この非常に基本的なwsgiアプリケーションを実行すると、まったく同じエラーが発生します。
#!/usr/bin/python
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]