3 Deploying with ``mod_wsgi``
4 ===========================
6 ``mod_wsgi`` makes it possible to run a WSGI_ application (such as OpenERP)
7 under the Apache_ HTTP server.
9 .. _WSGI: http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
10 .. _Apache: https://httpd.apache.org/
15 Similarly to :doc:`deployment-gunicorn`, running OpenERP behind Apache with
16 ``mod_wsgi`` requires to modify the sample ``openerp-wsgi.py`` script. Then
17 that Python script can be set in the Apache configuration.
19 Python (WSGI) application
20 -------------------------
22 Apache needs a Python script providing the WSGI application. By default the
23 symbol looked up by Apache is ``application`` but it can be overidden with the
24 ``WSGICallableObject`` directive if necessary. A sample script
25 ``openerp-wsgi.py`` is provided with OpenERP and you can adapt it to your
26 needs. For instance, make sure to correctly set the ``addons_path``
27 configuration (using absolute paths).
30 The script provided to Apache has often the extension ``.wsgi`` but the
31 ``openerp-wsgi.py`` script will do just as fine.
36 In Apache's configuration, add the following line to activate ``mod_wsgi``::
38 LoadModule wsgi_module modules/mod_wsgi.so
40 Then a possible (straightforward, with e.g. no virtual server) configuration is
43 WSGIScriptAlias / /home/thu/repos/server/trunk/openerp-wsgi.py
44 WSGIDaemonProcess oe user=thu group=users processes=2 python-path=/home/thu/repos/server/trunk/ display-name=apache-openerp
47 <Directory /home/thu/repos/server/trunk>
52 The ``WSGIScriptAlias`` directive indicates that any URL matching ``/`` will
53 run the application defined in the ``openerp-wsgi.py`` script.
55 The ``WSGIDaemonProcess`` and ``WSGIProcessGroup`` directives create a process
56 configuration. The configuration makes it possible for isntance to specify
57 which user runs the OpenERP process. The ``display-name`` option will make the
58 processes appear as ``apache-openerp`` in ``ps`` (instead of the normal
61 Finally, it is necessary to make sure the source directory where the script can
62 be found is allowed by Apache with the ``Directory`` block.
64 ``mod_wsgi`` supports a lot of directives, please see this ``mod_wsgi`` wiki
65 page for more details:
66 http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives.
71 When the Apache configuration changes, it is necessary to restart Apache, e.g. with::
73 /etc/init.d/httpd restart