Python脚本未在Apache2 / OS X El Capitan上与Mod_WSGI一起运行

时间:2015-11-08 18:26:46

标签: python apache mod-wsgi osx-elcapitan

我正在尝试在Apache2 / OS X El Capitan系统上运行Mod_WSGI(与PIP一起安装,正如GrahamDumpleton在https://github.com/GrahamDumpleton/mod_wsgi/issues/98中建议的那样)运行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

httpd.conf部分加载mod_wsgi:

LoadModule wsgi_module /Library/Python/2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so

任何帮助都将受到超级赞赏。

非常感谢。

1 个答案:

答案 0 :(得分:0)

你需要一行指向httpd-vhosts.conf中的脚本:

WSGIScriptAlias /myapp /Applications/MAMP/htdocs/gorilla/wsgi-scripts/myapp.wsgi