如何使用mod_wsgl而不使用CGI来使用apache使用apache来显示“Hello world”

我已经安装了Python,Apache。 命令行程序正在使用python

我有两个虚拟主机在Apache

site1.local site2.local 

我想要的是我把文件放在site1的根目录下,并在浏览器中显示你好

只有mod_wsgl没有cgi

这是最简单的forms

使用以下内容创build一个名为hello_world.wsgi的文件。 这应该在DocumentRoot之外,以便Apache无法将其作为纯文本提供:

 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] 

然后configuration您的虚拟主机来提供该脚本底下的所有请求:

 WSGIScriptAlias / <path_to_script>/hello_world.wsgi