How to deploy to a web server

Foreman comes with the default Python server, which when run will run Foreman in the localhost on port 5000. This is fine when it’s just one person using Foreman or its being used on a shared machine, bet it’s likely you’ll want to deploy Foreman onto a webserver so it can be accessed by lots of people. Below is a guide if you are using Apache on Linux.

  1. Download mod_wsgi. On Debian this can be done via:
apt-get install libapache2-mod-wsgi
  1. Create a foreman.wsgi file with the following contents inside the foreman folder:
#!/usr/bin/env python
import sys, site
from os import path


site.addsitedir('[Path to Foreman package]')
config = '[Path to Foreman config file]'


def make_app():
from foreman.utils.utils import setup

from foreman.application import make_app
return make_app()

application = make_app()
  1. Finally, Apache needs configuring. An example is below:
<VirtualHost *>

    WSGIDaemonProcess foreman user=user1 group=group1 processes=2 threads=5
    WSGIScriptAlias / [Path to WSGI file]/foreman.wsgi

    <Directory [Path to Foreman]>
        WSGIProcessGroup foreman
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all

Documentation on mod_wsgi can be found here.