How To Deploy Odoo/OpenERP Using mod_proxy and mod_wsgi On Ubuntu/Linux Servers

In last blog I explained “How To Install Openerp” In this blog I will describe “How to deploy OpenERP” using mod_proxy and mod_wsgi hand in hand with Apache2 on Linux/Ubuntu Server.

While installing OpenERP you might came across a requirement to rid out the 8069 port from OpenERP URL. So here is the solution deploy OpenERP using any one of these method.

Install ‘apache2’ on Ubuntu Server:

To deploy OpenERP the major component we need is web server we are using apache2 as web server which is the most widely used web server in the world. Use following command to install apache2 on any Ubuntu server.

sudo apt-get install apache2

Deploy using mod_proxy:

For this method we need complete OpenERP installation with the start up script.

Step 1: Enable required apache modules:

For deploying OpenERP using mod_proxy all we need to enable some apache modules like proxy_http, headers, rewrite

sudo a2enmod proxy_http headers rewrite

Step 2: Create Site Configuration file in apache:

Create a new virtual host configuration file in apache

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

With following content

<VirtualHost *:80>
    ServerAlias * // Use this if you want dbfillter on subdomain
    ErrorLog /var/log/openerp/openerp-error.log
    CustomLog /var/log/openerp/openerp-access.log combined
    <Proxy *>
        Order deny,allow
        Allow from all
    ProxyRequests Off
    ProxyPass /
    ProxyPassReverse /
    ProxyVia On
    LogLevel warn

Its done.

Deploy using mod_wsgi:

For this method we need OpenERP installation only we don’t need boot script and configuration file as described in previous post. We will create new configuration file for this deployment.

Step 1: Install & Enable mod_wsgi modules:

In previous we didn’t install any module as all that modules comes with apache by default but we need to install and enable the mod_wsgi before we use it.

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 file in openerp root folder (ex. /opt/openerp/ with following content.

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

# Equivalent of --load command-line option
openerp.conf.server_wide_modules = ['web']
conf =

# 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 = ''
pidfile = ''
workers = 4
timeout = 240
max_requests = 2000

Step 3: Create Site Configuration file in apache:

Create a new virtual host configuration file in apache

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

With following content

<VirtualHost *:80>
    ServerAlias * // Use this if you want dbfillter on subdomain
    WSGIScriptAlias / /opt/openerp/
    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
    <Directory /opt/openerp>
        Order allow,deny
        Allow from all

Here user=ubuntu is a system user in my case its ubuntu you should use your server user.

Its Done.

Configure For db filter:

If you want db filter on subdomain you can use ServerAlias in apache configuration in addition you need some changes in openERP configuration file /opt/openerp/openerp/tools/ change db-filter value to '%d'

 dest="dbfilter", default='%d'

Now you can access you openerp db using the link

Hope you find this tutorial helpful. Feel free to ask questions! Don’t forget to like or to leave a comment if its really help you.


17 thoughts on “How To Deploy Odoo/OpenERP Using mod_proxy and mod_wsgi On Ubuntu/Linux Servers”

  1. Well, I have installed OpenERP 7 on my server using the apt-get method, not “built” it, so the location of the files change (obviously). Will it work on the “installation” as well?



    1. Well installation from apt-get method changes the addons and server locations. In the installation I mention your copy of addons will be in python library but still you can use your addons folder.


  2. Hello, your articles are very interesting and helpful.
    I have a question, I hope you can help me:
    If I want to filter the DB by subdomain, ie: (select the DB “pharmacy”) (select the DB “cellar”) (select the DB “shoe”)
    I use the following:
    And it works great!
    But if I require filter the DB by domain, ie: (select the DB “pharmacy”) (select the DB “cellar”) (select the DB “shoe”)
    So what I should put in “–db-filter”?
    or, how should I do it?
    I use Odoo 8 and Ubuntu 14.04
    Of course, thank you very much for your help and cooperation!


    1. Hello thanks for your comment first. If you want to achive this you can deploy openerp using wsgi and for each domain you can creat different wsgi configuration file and specify different db names in db filter option this is the one approach you can also make make coding level change for that you need to overide the function dblist from web module.


    2. I was looking for a similar solution, and think that an approach could be something like:

      1) define in some place of the code the following:

      sites_database = {

      2) then define default like this:

      default = sites_database[‘%h’]

      I did not tested this yet, but the problem I have found is that the line where dest=”dbfilter”, default=’%d’ is, in Odoo V8 says:

      group.add_option(“–db-filter”, dest=”dbfilter”, my_default=’.*’,
      help=”Filter listed database”, metavar=”REGEXP”)

      And I am not sure if this is the same.


  3. Thanks for the great article.

    My question is how to remove or change the /page/ or added level within the modules url with url rewrites. Change to

    When you have a page structure like this it really effects Search Engine Friendly URL’s and SEO, especially once you implement the Ecommerce side.

    I am hoping there is an easy way of removing or rewriting these URL’s.

    Thanks for your time and consideration regarding this matter.


  4. I managed to install Odoo 8 on an Ubuntu VPS by following the instructions at

    I use Odoo with multiple subdomains and databases, so I installed mod_wsgi as described here and added –db-filter=^%d$ in the Odoo config file.

    Please note, you have to use database name same as subdomain name and everything works like a charm.


  5. In your experience, which of both configuration (proxy or wsgi) is better in performance? I could not check both yet, but I think mod_proxy could be better.. Am I wrong?


  6. Hello,

    Thanks a lot for a very useful article. I wonder if it’s possibile to build odoo on a server, and run apache wsgi_mod in another server?


      1. Thank you very much. Sorry if my question may sounds stupid, I haven’t found an answer for it anywhere. My question is, if I build odoo in server, postgres in another server, then config apache wsgi_mod in another server (let say so that my users go to the application by typing in your browser — will it be more secure?
        And 2nd question is, is it possible to run apache web server in one server and read config files & source files from another server, like I described above? Is it Apache ZooKeeper?


      2. No apache will not read a file from another server. If you are trying to do this for security purpose you can have SSL certificates installed in apache for odoo. You can keep Odoo on one server and Postgres i.e database server on another server. But what you are trying is not seems to be possible.


  7. Hello Swapnil,

    We just migrated to Odoo and I need to redirect some old URLs. Is there anyway to redirect old URLs to the new corresponding pages using mod_rewrite or proxyPass?

    Since there is no webroot folder, I don’t even know where I would put a .htaccess file.


    1. Hello Brad,
      You have two option to do this
      1) you can directly redirect URL from domain panel to new URL/domain
      2) you can have Apache configuration to redirect the old URLs permanent to new URL to do this you can use bellow small Apache configuration

      Redirect permanent /

      This is a simplest way to accomplish this through Apache. Using mod_rewrite module is bit complicated.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s