我正在尝试在 mac osx 上的默认 apache 服务器中安装 mod_wsgi 模块。我正在关注这个人的教程。我已经到了将模块添加到 apache 配置的部分,我插入了这两行:
$ sudo nano /private/etc/apache2/httpd.conf
...
LoadModule wsgi_module libexec/apache2/mod_wsgi.so
WSGIScriptAlias / /Library/WebServer/Documents/
...
回到终端我输入:
sudo /usr/sbin/apachectl restart
当我在浏览器中访问 localhost/testpy.py 时,我收到一条错误消息,提示无法连接到本地主机。这是我的testpy.py
文件:
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]
编辑
当我添加了这两行代码时,apache 错误日志不会产生任何内容。当我将它们取出并转到一个我知道在错误日志中得到它之前有效的 URL 时:
caught SIGTERM, shutting down
Init: Session Cache is not configured [hint: SSLSessionCache]
httpd: Could not reliably determine the server's fully qualified domain name, using my-machine.local for ServerName
Digest: generating secret for digest authentication ...
Digest: done
Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations