nilmdb/docs/wsgi.md
Jim Paris dccb3e370a WSGI config needs to specify application group
This ensures that the same Python sub-instance handles the request,
even if it's coming in from two different virtual hosts.
2013-03-30 15:56:02 -04:00

1016 B

WSGI Application in Apache

Install apache2 and libapache2-mod-wsgi

We'll set up the database server at URL http://myhost.com/nilmdb. The database will be stored in /home/nilm/db, and the process will run as user nilm, group nilm.

First, create a WSGI script /home/nilm/nilmdb.wsgi containing:

import nilmdb.server
application = nilmdb.server.wsgi_application("/home/nilm/db", "/nilmdb")

The first parameter is the local filesystem path, and the second parameter is the path part of the URL.

Then, set up Apache with a configuration like:

<VirtualHost>
    WSGIScriptAlias /nilmdb /home/nilm/nilmdb.wsgi
    WSGIApplicationGroup nilmdb-appgroup
    WSGIProcessGroup nilmdb-procgroup
    WSGIDaemonProcess nilmdb-procgroup threads=32 user=nilm group=nilm

    # Access control example:
    <Location /nilmdb>
        Order deny,allow
        Deny from all
        Allow from 1.2.3.4
    </Location>
</VirtualHost>