Installing and configuring Odoo with mod_wsgi

In this article, we will show you how to install Odoo 10 on an Ubuntu 16.04 VPS with Apache2 and mod_wsgi, which is an Apache module that implements a WSGI compliant hosting interface for Python based web applications such as Odoo on top of the Apache web server. There are several ways to install Odoo, but in this tutorial, we will be installing the latest Odoo 10 from source using a Python virtual environment. This guide should work on other Linux VPS systems as well, but has been tested and written for an Ubuntu 16.04 VPS.

Updating the system and installing the required packages

                      sudo apt update 
apt -y upgrade
sudo apt-get install git python-pip python-dev 
    python-virtualenv libevent-dev gcc libjpeg-dev libxml2-dev 
    libssl-dev libsasl2-dev node-less libldap2-dev libxslt-dev

Installing PostgreSQL

Installing PostgreSQL with apt is quick and easy.

                      sudo apt install postgresql-9.5 postgresql-server-dev-9.5
sudo systemctl enable postgresql.service
sudo systemctl start postgresql.service

Creating an Odoo user

Create a system user odoo with the following command:

                      sudo adduser --system --group odoo --home /opt/odoo

Create a PostgreSQL database user with the following command:

                      su - postgres -c "createuser --createdb --username postgres --no-createrole --no-superuser --no-password odoo"

Install Odoo

Switching odoo user and cloning Odoo 10 from GitHub:

                      sudo su - odoo -s /bin/bash
git clone --depth 1 --branch 10.0 --single-branch /opt/odoo

Create a python virtual environment and install all requirements:

                      cd /opt/odoo
pip install -r requirements.txt

When the installation is complete, switch back to your sudo user:


Create a config file by copying the default file :

                      sudo cp /opt/odoo/setup/ /opt/odoo/setup/

Open the config file

                      sudo nano /opt/odoo/setup/

change the path to addons:

                      conf['addons_path'] = 'addons'

and set a master admin password:

                      conf['admin_passwd'] = 'my_secret_password'

If you want to print PDF reports in Odoo, you need to install the wkhtmltopdf package:

                      sudo apt -y install wkhtmltopdf

Installing Apache and mod_wsgi

If you don’t have Apache installed on your system, install it with the following command:

                      sudo apt update
sudo apt install apache2

To install and enable mod_wsgi, run the following commands:

                      sudo apt install libapache2-mod-wsgi
sudo a2enmod wsgi

Create Apache virtual host directive for domain:

                      sudo nano /etc/apache2/sites-available/odoo.conf
                      <VirtualHost *:80>

    ErrorLog ${APACHE_LOG_DIR}/odoo-error.log
    CustomLog ${APACHE_LOG_DIR}/odoo-access.log combined

    <Directory /opt/odoo/setup>
            Require all granted

    WSGIDaemonProcess odoo user=odoo group=odoo python-home=/opt/odoo/venv/ python-path=/opt/odoo
    WSGIProcessGroup odoo
    WSGIScriptAlias / /opt/odoo/setup/

</VirtualHost *:80 >

Activate the virtual host by creating a symlink and restarting Apache.

                      sudo a2ensite odoo
sudo systemctl restart apache2

That’s all. You have successfully installed Odoo with Apache2 and mod_wsgi on your Ubuntu 16.04 VPS. Now open your browser, enter your site url and create a user and admin database.

For more information on how to manage your Odoo installation, please refer to Odoo documentation

Related Posts