mod_wsgi

Issue #61 resolved
Daniel Smith created an issue

Has anyone successfully gotten Foreman to port to Apache using mod_wsgi? I have no idea what I'm doing there, and have tried following the instructions in the blog post, but Apache2 will not start when the virtual site is active.

If anyone has an idea, I'd love to hear it.

Comments (2)

  1. Daniel Smith reporter

    I've gotten it figured out. I copied the root foreman folder into /var/www/html and ran run_foreman with the setup option. That copied all the files into /usr/local/lib/python2.7/dist-packages/Foreman_Forensics-0.0.1-py2.7.egg.

    Something I've learned here... altering the contents of /var/www/html doesn't change what's delivered by Apache, but altering the contents of the Python library did deliver a difference.

    My WSGI file is stored at /var/www/html (yes, the same location as run_foreman.py), and contains the following:

    #!/usr/bin/env python
    import sys, site
    from os import path
    
    sys.path.append(path.dirname(__file__))
    
    site.addsitedir('/var/www/html/foreman/')
    config = '/var/www/html/foreman/config/config.ini'
    
    sys.path.append(path.dirname(__file__))
    
    def make_app():
        from foreman.utils.utils import setup
        setup(config)
    
        from foreman.application import make_app
        return make_app()
    
    application = make_app()
    

    My VirtualHost file, /etc/apache2/sites-available/foreman.conf is as follows:

    <VirtualHost *:80>
        ServerName foreman
    
        WSGIDaemonProcess foreman user=www-data group=www-data processes=2 threads=5
        WSGIScriptAlias / /var/www/html/foreman.wsgi
    
        <Directory /var/www/html>
        WSGIProcessGroup foreman
        WSGIApplicationGroup %{GLOBAL}
        Order deny, allow
        Allow from all
        Require all granted
        </Directory>
    </VirtualHost>
    

    Finally, after doing an a2ensite foreman.conf, Apache restarted without an error.

    I noticed that there was no "files" directory at usr/local/lib/python2.7/dist-packages/Foreman_Forensics-0.0.1-py2.7.egg/foreman. I did a sudo cp -R /var/www/html/foreman/files usr/local/lib/python2.7/dist-packages/Foreman_Forensics-0.0.1-py2.7.egg/foreman.

    I then had to sudo chmod -R 777 usr/local/lib/python2.7/dist-packages/Foreman_Forensics-0.0.1-py2.7.egg/foreman/files to give Apache permission to save documents in that location.

    After setting up a local DNS record, I'm now good to go on my disconnected network.

    Thank you!!

  2. Log in to comment