0

使用 Apache2.2 Python 2.7.3

在 httpd.conf 中使用 LoadModule wsgi_module modules/mod_wsgi-win32-ap22py27-3.3.so

python完美执行,但不是在本地主机上

在 localhost 中,未处理以下脚本,error.log 中也未出现任何错误

还有什么要检查的?

使用测试脚本

#!/usr/bin/python2.7.3

# enable debugging
import cgitb
cgitb.enable()

print "Content-Type: text/plain\r\n\r\n"
print

print "Hello World!"
4

1 回答 1

0

mod_wsgi 是一个用于运行WSGI应用程序的 Apache 模块。您提供的示例脚本不是 WSGI 应用程序,它只是普通的 CGI 脚本。

WSGI 中的 Hello World 如下所示:

def application(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    yield 'Hello World\n'

另一方面,如果你想使用老式的 CGI,你应该使用Apache 的 mod_cgi。请注意,这是一种非常过时且低效的服务器端编程方式,因此我不推荐它用于任何严重的事情。

于 2013-04-03T14:16:28.690 回答