How To Deploy Odoo Using mod_proxy and mod_wsgi On Ubuntu Servers

mod_proxy is an optional module for the Apache HTTP Server. This module implements a gateway, proxy or cache for Apache. It implements proxying capability for Apache J Serv Protocol version 1.3, FTP, CONNECT (for SSL), HTTP/0.9, HTTP/1.0, and HTTP/1.1.


With mod_proxy it is possible to set various web framework based applications as virtual hosts as well.

mod_wsgi is an Apache HTTP Server module by Graham Dumpleton that provides a WSGI compliant interface for hosting Python 2.3+ based web applications under Apache.

Follow the underlying steps to deploy Odoo using mod_proxy and mod_wsgi On Ubuntu Servers:

Install apache2 on Ubuntu Server
sudo apt-get install apache2

1) Deploy using mod_proxy:

Step 1: Enable required apache modules:
sudo a2enmod proxy_http headers rewrite

Step 2: Create Site Configuration file in apache:
sudo nano /etc/apache2/site-available/openerp
With following content
ServerName domain.com
ServerAlias *.domain.com // Use this if you want dbfillter on subdomain
ErrorLog /var/log/openerp/openerp-error.log
CustomLog /var/log/openerp/openerp-access.log combined
Order deny,allow
Allow from all
ProxyRequests Off
ProxyPass / http://domain.com:8069/
ProxyPassReverse / http://domain.com:8069/
ProxyVia On
LogLevel warn

2) Deploy using mod_wsgi:

Step 1: Install & Enable mod_wsgi modules:
sudo apt-get install libapache2-mod-wsgi
sudo a2enmod wsgi

Step 2: Create a openerp configuration file:

For this type of deployment we will create a new configuration file and will not use traditional /etc/openerp-server.conf file. Create a openerp-wsgi.py file in openerp root folder (ex. /opt/openerp/openerp-wsgi.py) with following content.

import openerp
#———————————————————-
# Common
#———————————————————-
openerp.multi_process = True # Nah!

# Equivalent of –load command-line option
openerp.conf.server_wide_modules = [‘web’]
conf = openerp.tools.config

# Path to the OpenERP Addons repository (comma-separated for
# multiple locations)

conf[‘addons_path’] = ‘/opt/openerp/openerp’ #path from home folder to openerp

# Optional database config if not using local socket
#conf[‘db_name’] = ‘mycompany’
conf[‘db_host’] = ‘localhost’
conf[‘db_user’] = ‘openerp’
conf[‘db_port’] = 5432
conf[‘db_password’] = ‘openerp’

#———————————————————-
# Generic WSGI handlers application
#———————————————————-
application = openerp.service.wsgi_server.application

#———————————————————-
# Gunicorn
#———————————————————-
# Standard OpenERP XML-RPC port is 8069
bind = ‘0.0.0.0:8069’
pidfile = ‘.nbserp.pid’
workers = 4
timeout = 240
max_requests = 2000

Step 3: Create Site Configuration file in apache:

sudo nano /etc/apache2/site-available/openerp-wsgi

With following content
ServerName domain.com
ServerAlias *.domain.com // Use this if you want dbfillter on subdomain
WSGIScriptAlias / /opt/openerp/openerp-wsgi.py
WSGIDaemonProcess oe user=ubuntu group=ubuntu processes=2 python-           path=/opt/openerp/ display-name=apache-openerp
WSGIProcessGroup oe
ErrorLog /var/log/openerp/openerp-error.log
CustomLog /var/log/openerp/openerp-access.log combined

Order allow,deny
Allow from all

Get more information here!

You must be logged in to post a comment.