下运行的mod_wsgi CherryPy的 [英] Running CherryPy under mod_wsgi
问题描述
我想获得在Ubuntu下的Apache2 / mod_wsgi的运行CherryPy的应用程序。我下面教程中介绍 rel=\"nofollow\">,和我的配置几乎是相同的。当访问该网站的根目录下,我收到了500内部服务器错误。在日志中唯一的错误是:
[周一12月3 4时43分06秒2012] [错误] [客户64.189.251.239]脚本头premature结束:index.py
我尝试了好几种变化的教程,但我没有收到任何显著的错误。任何想法?
我的Apache 虚拟主机
:
...
WSGIScriptAlias / /var/www/example.com/uba/index.py
DocumentRoot的/var/www/example.com/uba/
<目录/>
选项+ ExecCGI指标的FollowSymLinks
所有的AllowOverride
< /目录><目录/var/www/example.com/uba/>
选项+ ExecCGI -Indexes -FollowSymLinks -MultiViews
WSGIApplicationGroup%{} GLOBAL
所有的AllowOverride
为了允许,拒绝
所有允许
< /目录>
...
我index.py脚本:
#!的/ usr / bin中/蟒蛇进口SYS
为sys.stderr = sys.stderr来进口的atexit
进口螺纹
进口的CherryPycherrypy.config.update({'环境':'嵌入式'})如果CherryPy的.__版本__ startswith('3.0')和cherrypy.engine.state == 0:
cherrypy.engine.start(阻塞= FALSE)
atexit.register(cherrypy.engine.stop)根类(对象):
高清指数(个体经营):
回报世界,你好!
index.exposed = TRUE应用= cherrypy.Application(根(),SCRIPT_NAME =无,配置=无)
更新#1:
运行这个很基本的WSGI应用程序产生完全相同的错误:
#!的/ usr / bin中/蟒蛇高清应用(ENVIRON,start_response):
状态=200 OK
输出=世界,你好! response_headers = [('内容类型','text / plain的'),
(内容长度,STR(LEN(输出)))]
start_response(状态,response_headers) 返回[输出]
我建议你用一个超级简单的WSGI应用程序更换您的CherryPy index.py脚本测试你的Apache配置。
高清应用(ENVIRON,start_response):
状态=200 OK
输出=世界,你好! response_headers = [('内容类型','text / plain的'),
(内容长度,STR(LEN(输出)))]
start_response(状态,response_headers) 返回[输出]
确认试图用一个CherryPy的脚本之前的作品。
I am trying to get a CherryPy app running under apache2/mod_wsgi on ubuntu. I am following the tutorial outlined here, and my config is almost identical. When visiting the root of the site, I receive a 500 Internal Server Error. The only error in the log is:
[Mon Dec 03 04:43:06 2012] [error] [client 64.189.251.239] Premature end of script headers: index.py
I have tried several variations to the tutorial, but I am not receiving any significant errors. Any ideas?
My 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>
...
My index.py script:
#!/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)
UPDATE #1:
Running this very basic wsgi application produces the exact same error:
#!/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]
I suggest you test your apache configuration by replacing your cherrypy index.py script with a super simple wsgi app.
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]
Make sure that works before trying to use a cherrypy script.
这篇关于下运行的mod_wsgi CherryPy的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!