How To Deploy Odoo/OpenERP 8 With mod_wsgi On Ubuntu/Linux Server (VPS/EC2)

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

Install ‘apache2’ on Ubuntu Server:

To deploy Odoo 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_wsgi:

We will create new configuration file for this deployment.

Step 1: Install & Enable mod_wsgi modules:

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 odoo 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 odoo root folder (ex. /opt/odoo/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/odoo/openerp/addons,/opt/odoo/addons' #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'] = 'odoo'
conf['db_port'] = 5432
conf['db_password'] = 'odoo'

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

You need to give two addons path for odoo in openerp-wsgi.py file separated with comma.

Step 3: Create Site Configuration file in apache:

Create a new virtual host configuration file in apache

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

If you are using apache 2.4 you need to have site configuration file name as below.

sudo nano /etc/apache2/site-available/odoo.conf

With following content

<VirtualHost *:80>
    ServerName domain.com
    ServerAlias *.domain.com // Use this if you want dbfillter on subdomain
    WSGIScriptAlias / /opt/odoo/openerp-wsgi.py
    WSGIDaemonProcess oe user=ubuntu group=ubuntu processes=2 python-           path=/opt/odoo/ display-name=apache-openerp
    WSGIProcessGroup oe
    ErrorLog /var/log/odoo/odoo-error.log
    CustomLog /var/log/odoo/odoo-access.log combined
    <Directory /opt/odoo>
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

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

Its Done.

Force default page to the website in openerp 8:

If you want default page of odoo to your website  you can use you need some changes in odoo configuration file /opt/odoo/openerp/tools/config.py change db-filter value to your db name

 dest="dbfilter", default='YOUR_DB_NAME'

Now your default page would be your website.

Notes:

  • Website module should be installed in the database.
  • Apache used for this deployment is version 2.2.

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.

Advertisements

10 thoughts on “How To Deploy Odoo/OpenERP 8 With mod_wsgi On Ubuntu/Linux Server (VPS/EC2)”

  1. It’s hard to find your articles in google. I found it on 21 spot,
    you should build quality backlinks , it will
    help you to increase traffic. I know how to help you, just type in google – k2 seo
    tricks

    Like

  2. Thanks for sharing this how to!
    I currently use reverse proxy on a server with multiple odoo databases mapped (through odoo config file dbfilter option) to multiple domains or subdomains.
    Can you please reference some advantages of using mod_wsgi instead of proxy_http and proxy modules in order to reverse proxy through apache to the odoo port (8069) ?

    Like

  3. Good tuto, but let’s say I have 2 databases on my odoo server and I want 2 web sites, I understand that mod_wsgi should do the trick with the appache configuration. Unfortunately, in my case mywebsite:8069 always shows the same server, what is the next step so we can have http://www.site1.com one the first database ans http://www.site2.com on the second database.

    Thanks a lot

    Like

  4. Sorry, it is not working from my side. After configuration like you said, then, when I access localhost, it still is the apahce2 default welcome page.
    Why is this, can you give me some help?

    Like

    1. @wesley The blog i write is specially for VPS/EC2, but still I will help you in this

      If you are working on local machine you should edit /etc/hosts with something like this:

      127.0.0.1 foo.localhost

      127.0.0.1 bar.localhost

      where foo and bar are the db names.

      Your virtual host file should look like this:

      ServerName localhost

      ServerAlias *.localhost // 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://localhost:8069/

      ProxyPassReverse / http://localhost:8069/

      ProxyVia On

      LogLevel warn

      After that write dbfilter = ^%d$ in your openerp/tools/config.py file. After that restart apache2 and openerp.

      In case you are doing all this on VPS and you bough a domain from domian provider, then you dont need to edit/etc/hosts file.

      Like

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s