【问题标题】:Python scripts not running with Mod_WSGI on Apache2 / OS X El CapitanPython 脚本未在 Apache2 / OS X El Capitan 上与 Mod_WSGI 一起运行
【发布时间】: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


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-11-02
      • 1970-01-01
      • 2017-01-09
      • 1970-01-01
      • 2017-02-27
      • 2016-12-30
      • 1970-01-01
      相关资源
      最近更新 更多