From 85baacecc198721596b5d69478c793414f56435c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 25 Sep 2019 14:17:44 -0500 Subject: [PATCH] Add `apache.install_wsgi()` convenience function although you really shouldn't use it --- rattail_fabric2/apache.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rattail_fabric2/apache.py b/rattail_fabric2/apache.py index 95cc259..dd4e788 100644 --- a/rattail_fabric2/apache.py +++ b/rattail_fabric2/apache.py @@ -38,6 +38,24 @@ def install(c): apt.install(c, 'apache2') +def install_wsgi(c, python_home=None, python3=True): + """ + Install the mod_wsgi Apache module, with optional ``WSGIPythonHome`` value. + + NOTE: you probably should not use this! reverse proxy seems more robust + """ + if python3: + apt.install(c, 'libapache2-mod-wsgi-py3') + else: + apt.install(c, 'libapache2-mod-wsgi') + if python_home: + if get_version(c) == 2.2: + c.sudo("bash -c 'echo WSGIPythonHome {} > /etc/apache2/conf.d/wsgi'".format(python_home)) + else: # assuming 2.4 + c.sudo("bash -c 'echo WSGIPythonHome {} > /etc/apache2/conf-available/wsgi.conf'".format(python_home)) + enable_conf(c, 'wsgi') + + def get_version(c): """ Fetch the version of Apache running on the target system