Apache 运行 在哪个端口

Apache running on which Port

有没有一种方法可以从 Python 程序(使用 mod_wsgi 的 Web 应用程序)

中以编程方式找出 Apache 的 运行 端口

我总是可以在 httpd.conf 上进行 grep,但想知道是否有其他标准的编程方式可以实现这一点。

环境变量SERVER_PORT应该给你:

def application(env, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
    return [ env['SERVER_PORT'] ]