In this post, I will show you how to setup odoo port 80 so that users can easily access the service without typing the port number (say, 8069). This means that you can access your odoo instance as example.com instead of example.com:8069.

Our deployment will involve running the odoo instance as a mod_wsgi script. To achieve this, we will create a wsgi script file as well as a new configuration file for apache to handle incoming requests.

Install Apache Web Server on Ubuntu

First, we need to install apache web server. Many OS distributions under major VPS offerings will have this already set up. It is therefore worth checking using the command:

sudo service apache2 status

However, if apache is not installed, install it by running the following command on terminal:

sudo apt-get install apache2

Install and enable wsgi apache

In many cases, the mod_wsgi module is not installed and enabled in apache out of the box. We therefore need to install and enable it using the following commands.

sudo apt-get install libapache2-mod-wsgi

sudo a2enmod wsgi

Create odoo wsgi script

This mod_wsgi script will run the odoo instance behind apache web server.

Navigate to the directory where odoo is installed and create a file called odoo-wsgi.py with the following contents. In my case, odoo is installed under /opt/odoo. (Note that that is the directory that contains odoo-bin in version 10 and 11 or odoo.py file.


# WSGI Handler configuration file.
import odoo
# Common
odoo.multi_process = True
# Equivalent of --load command-line option
odoo.conf.server_wide_modules = ['web'] conf = odoo.tools.config
# Path to the Odoo Addons directory/directories (comma-separated )
conf['addons_path'] = '/opt/odoo/odoo/addons,/opt/odoo/addons,/opt/odoo/custom/addons'
# Optional database config if not using local socket
conf['db_name'] = 'demo_db_name'
conf['db_host'] = 'localhost'
conf['db_user'] = 'odoo'
conf['db_port'] = 5432
conf['db_password'] = False
conf['xmlrpc_port'] = 8069
# Generic WSGI handlers application
application = odoo.service.wsgi_server.application
odoo.service.server.load_server_wide_modules()
# Gunicorn
# Standard OpenERP XML-RPC port is 8069
bind = '127.0.0.1:8069'
pidfile = '.gunicorn.pid'
workers = 4
timeout = 240
max_requests = 2000

Create apache configuration file under sites-enabled
Next we need to create a site configuration file to handle requests that come through our domain example.com. You will of course replace the domain example.com with your domain name.
sudo vi /etc/apache2/sites-enabled/odoo.conf

 

    ServerName example.com
    ServerAlias *.example.com // You can achieve dbfillter using subdomains here
    WSGIScriptAlias / /opt/odoo/odoo-wsgi.py
    WSGIDaemonProcess oe user=odoo group=odoo processes=4 python-path=/opt/odoo/ display-name=apache-odoo-server python-home=/opt/ou11_venv/bin/
    WSGIProcessGroup oe
    ErrorLog /var/log/odoo/odoo-error.log
    CustomLog /var/log/odoo/odoo-server.log combined
    
        Require all granted
    

The python-home argument is the path to your python virtual environment on the apache wsgi script. Remove that if you are not using a virtual environment to run your odoo instance (highly recommended).

Summary
 

Addition:

I had a few issues running Odoo 11 as a wsgi script. After hours of seraching why my venv was not getting the required packages, I figured that there’s a separate version of wsgi_mod for python 3. To set it up:

  1. You probably already have mod_wsgi (for python 2>) So you need to uninstall it.
  2. a2dismod wsgi sudo apt-get remove libapache2-mod-wsgi

  3. Then install the right version of wsgi_mode for python 3
  4. $ sudo apt-get install libapache2-mod-wsgi-py3
    $ a2enmod wsgi

23Aug 2015
low cost erp kenya

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque non eleifend tellus. Ut dui velit, porttitor et accumsan ac, faucibus placerat sapien. Ut sapien erat, vulputate non ultricies id, venenatis ac mauris. Morbi sit amet diam ut tortor pellentesque gravida vitae id eros. Aliquam gravida lacus massa, eu rhoncus metus. Nulla facilisi. Morbi dignissim metus nec lacus imperdiet sagittis. Nam in dolor eu risus bibendum vestibulum at vitae risus. Aliquam convallis euismod eros ac dignissim. Aliquam quis sapien sapien, quis semper felis. Aliquam tortor nulla, sodales et molestie et, euismod vel magna. Vivamus non risus id purus scelerisque rutrum. Phasellus congue lectus quis erat convallis imperdiet.

18Feb 2018

In this article, I will capture my journey and help you upgrade Odoo 9 to version 10 The first step involves determining your database name, its odoo version and the version of odoo that you are going to upgrade it to. Database backup – I highly recommend that you take a backup of your before anything […]

24Feb 2018

In this post, I will show you how to setup odoo port 80 so that users can easily access the service without typing the port number (say, 8069). This means that you can access your odoo instance as example.com instead of example.com:8069. Our deployment will involve running the odoo instance as a mod_wsgi script. To […]