[IMP] models: move prefetching of records back to method _prefetch_field
[odoo/odoo.git] / doc / deployment-mod-wsgi.rst
1 .. _using-mod-wsgi:
2
3 Deploying with ``mod_wsgi``
4 ===========================
5
6 ``mod_wsgi`` makes it possible to run a WSGI_ application (such as OpenERP)
7 under the Apache_ HTTP server.
8
9 .. _WSGI: http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
10 .. _Apache: https://httpd.apache.org/
11
12 Summary
13 -------
14
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.
18
19 Python (WSGI) application
20 -------------------------
21
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).
28
29 .. note ::
30   The script provided to Apache has often the extension ``.wsgi`` but the
31   ``openerp-wsgi.py`` script will do just as fine.
32
33 Apache Configuration
34 --------------------
35
36 In Apache's configuration, add the following line to activate ``mod_wsgi``::
37
38   LoadModule wsgi_module modules/mod_wsgi.so
39
40 Then a possible (straightforward, with e.g. no virtual server) configuration is
41 as follow::
42
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
45   WSGIProcessGroup oe
46
47   <Directory /home/thu/repos/server/trunk>
48       Order allow,deny
49       Allow from all
50   </Directory>
51
52 The ``WSGIScriptAlias`` directive indicates that any URL matching ``/`` will
53 run the application defined in the ``openerp-wsgi.py`` script.
54
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
59 ``httpd``).
60
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.
63
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.
67
68 Running
69 -------
70
71 When the Apache configuration changes, it is necessary to restart Apache, e.g. with::
72
73   /etc/init.d/httpd restart