【发布时间】:2016-02-09 09:49:07
【问题描述】:
我正在尝试在 Apache2 / OS X El Capitan 系统上借助 Mod_WSGI(如 GrahamDumpleton 在https://github.com/GrahamDumpleton/mod_wsgi/issues/98 中建议的那样安装 PIP)运行 Python 脚本。但是经过两天的反复试验,我仍然失败了..:S
问题是脚本没有被执行,而是被视为一个静态文件——在我的浏览器中显示代码。
我没有看到什么或做错了什么?我的配置如下所示。
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]
httpd-vhosts.conf:
<VirtualHost *:80>
ServerName local.flipflopinteractive.com
ServerAdmin koen@flipflopinteractive.com
DocumentRoot "/Users/kdesterik/Sites/001_0001/dist/"
ErrorLog "/Users/kdesterik/Sites/001_0001/dist/error.log"
AddHandler cgi-script .py
<Directory "/Users/kdesterik/Sites/001_0001/dist/">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
将 localhost 映射到上面的 ServerName 的主机部分:
127.0.0.1 local.flipflopinteractive.com
加载 mod_wsgi 的 httpd.conf 部分:
LoadModule wsgi_module /Library/Python/2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so
任何帮助将不胜感激。
非常感谢。
【问题讨论】:
标签: python apache mod-wsgi osx-elcapitan