Knowledgebase

Question About Servers

How to Install Multiple Instances of Odoo on the same Ubuntu Machine Print

  • 0

This article will guide you through the installation and configuration process of multiple Odoo instances in an Ubuntu system. We will install two instances (Odoo 15 and 16).

Prerequisites

OS: Ubuntu 20.04

Resources: 2-core CPU & 2GB of RAM

Access: SSH connection to the server

Permissions: a user with 'sudo' privileges

Note: you can execute all of the commands below from the root user, but for security purposes, it is recommended that you use a separate user with sudo privileges.

Step 1: Log in to the Ubuntu server via SSH as the root user:

The first step in the installation is to connect to your server via ssh

You can log in to the server using ssh:

ssh username@IP_Address -p Port_number

e.g. ssh [email protected] -p 22

Step 2: Update Packages

Then let’s update existing Ubuntu packages and upgrade them to newer versions. The following commands will help you.

sudo apt-get update
sudo apt-get upgrade -y

Step 3: Install Dependencies

In this step, we need to install Git , Pip , Node.js , and development [tools required to build]

sudo apt install git python3-pip build-essential wget python3-dev python3-venv \
    python3-wheel libfreetype6-dev libxml2-dev libzip-dev libldap2-dev libsasl2-dev \
    python3-setuptools node-less libjpeg-dev zlib1g-dev libpq-dev \
    libxslt1-dev libldap2-dev libtiff5-dev libjpeg8-dev libopenjp2-7-dev \
    liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev libxcb1-dev

Step 4: Create Odoo users.

Create two users called odoo15 and odoo16 with home directory /opt/odoo15 and /opt/odoo16 respectively. This prevents the security risks posed by running Odoo under the root user. You can do it with these commands. You can give any name to the users. However, be careful to create PostgreSQL users with the same name.

sudo useradd -m -d /opt/odoo15 -U -r -s /bin/bash odoo15
sudo useradd -m -d /opt/odoo16 -U -r -s /bin/bash odoo16

Step 5: Install and configure PostgreSQL

In this step, you need to set up the database server. Odoo uses PostgreSQL as the database back-end. Install the database server for Odoo By using the following command.

sudo apt install postgresql -y

Now you need to create two PostgreSQL users for the handling of the database server i.e. PostgreSQL.  In our case, we will create the PostgreSQL users with the same names as the previously created system users i.e odoo15 and odoo16

sudo su - postgres -c "createuser -s odoo15"
sudo su - postgres -c "createuser -s odoo16"

Step 6: Installing wkhtmltopdf

Wkhtmltopdf is the package that allows Odoo to print PDF reports. It converts HTML (web page markup) to PDF, but it's not present in the official package list nor the EPEL repository. We’ll download and install the package from Github.

sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb

After it has downloaded, we'll use this command to install it.

sudo apt install ./wkhtmltox_0.12.5-1.bionic_amd64.deb

Step 7: Create Log Directories

Create directories where both Odoo instances will save log files. Use these commands to create the log directories.

sudo mkdir /var/log/odoo15
sudo chown odoo15:odoo15 /var/log/odoo15

sudo mkdir /var/log/odoo16
sudo chown odoo16:odoo16 /var/log/odoo16

Step 8: Installing and Configuring Odoo 15

First, we'll change the user to the one we created to handle the Odoo 15 instance i.e odoo15 using the following command.

sudo su - odoo15

Next, we'll clone the Odoo 15 source code from github.

git clone https://www.github.com/odoo/odoo --depth 1 --branch 15.0 /opt/odoo15/odoo

To separate Odoo's Python modules from the system's Python modules, we'll need to set up a Python Virtual Environment inside which we'll install Odoo. Use these commands to achieve this. 

cd /opt/odoo15
python3 -m venv odoo-venv

Then we activate the virtual environment.

source odoo-venv/bin/activate

All dependencies for Odoo are specified in the requirements.txt file. We'll use pip to install all required Python modules.

pip3 install wheel
pip3 install -r odoo/requirements.txt

When we're finished, we deactivate the virtual environment

deactivate

Step 9: Installing and Configuring Odoo 16

First, we'll change the user to the one we created to handle the Odoo 16 instance i.e odoo16 using the following command.

sudo su - odoo16

Next, we'll clone the Odoo 16 source code from Git Hub.

git clone https://www.github.com/odoo/odoo --depth 1 --branch 16.0 /opt/odoo16/odoo

To separate Odoo's Python modules from the system's Python modules, we'll need to set up a Python Virtual Environment inside which we'll install Odoo. Use these commands to achieve this. 

cd /opt/odoo16
python3 -m venv odoo-venv

Then we activate the virtual environment.

source odoo-venv/bin/activate

All dependencies for Odoo are specified in the requirements.txt file. We'll use pip to install all required Python modules.

pip3 install wheel
pip3 install -r odoo/requirements.txt

When we're finished, we deactivate the virtual environment

deactivate

Step 10: Create directories for the 3rd party add-ons

We’ll create new directories for the 3rd party addons, one for each odoo instance. Use the following commands

mkdir /opt/odoo15/odoo-custom-addons
mkdir /opt/odoo16/odoo-custom-addons

These directories should later be added to the addons_path parameter which defines a list of directories where Odoo searches for modules. After this step we will switch back to the sudo user using this command.

exit

Step 11: Create a configuration file for Odoo 15

The command below allows you to create and edit a *.conf file.

sudo nano /etc/odoo15.conf

Add the following configuration information to the file. 

Note: Remember to change the admin_passwd to something more secure.

We will configure the odoo 15 instance to listen on port 8069.

[options]
; This is the password that allows database operations:
admin_passwd = my_admin_passwd
db_host = False
db_port = False
db_user = odoo15
db_password = False
xmlrpc_port = 8069
longpolling_port = 8072
logfile = /var/log/odoo15/odoo.log
logrotate = True
addons_path = /opt/odoo15/odoo/addons,/opt/odoo15/odoo-custom-addons

Each Odoo instance must run on a different port to avoid conflicts. Note the different port numbers in the two configuration files.

Step 12: Create a configuration file for Odoo 16

The command below allows you to create and edit a *.conf file.

sudo nano /etc/odoo16.conf

Add the following configuration information to the file. 

Note: Remember to change the admin_passwd to something more secure.

We will configure the odoo 16 instance to listen on port 8070.

[options]
; This is the password that allows database operations:
admin_passwd = my_admin_passwd
db_host = False
db_port = False
db_user = odoo16
db_password = False
xmlrpc_port = 8070
longpolling_port = 8073
logfile = /var/log/odoo16/odoo.log
logrotate = True
addons_path = /opt/odoo16/odoo/addons,/opt/odoo16/odoo-custom-addons

Step 12: Creating Systemd Unit File for Odoo 15

This is a configuration ini-style file that holds configuration information about a service. We'll be creating a file named "odoo15.service".

sudo nano /etc/systemd/system/odoo15.service

Add the following configuration information to the file.

[Unit]
Description=Odoo16
Requires=postgresql.service
After=network.target postgresql.service

[Service]
Type=simple
SyslogIdentifier=odoo15
PermissionsStartOnly=true
User=odoo16
Group=odoo16
ExecStart=/opt/odoo15/odoo-venv/bin/python3 /opt/odoo15/odoo/odoo-bin -c /etc/odoo15.conf
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

With the next command, we notify systemd that the new file exists and reload the daemon.

sudo systemctl daemon-reload

Next, we start the Odoo service and enable it to run on system boot.

sudo systemctl enable --now odoo15

Now we check if the service is running.

sudo systemctl status odoo15

You should get the following output.

● odoo15.service - Odoo15
     Loaded: loaded (/etc/systemd/system/odoo15.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-10-28 09:56:28 UTC; 28s ago
...

This next command will allow you to check on the messages logged by the odoo15 service.

sudo journalctl -u odoo15

Step 13: Creating Systemd Unit File for Odoo 16

This is a configuration ini-style file that holds configuration information about a service. We'll be creating a file named "odoo16.service".

sudo nano /etc/systemd/system/odoo16.service

Add the following configuration information to the file.

[Unit]
Description=Odoo16
Requires=postgresql.service
After=network.target postgresql.service

[Service]
Type=simple
SyslogIdentifier=odoo16
PermissionsStartOnly=true
User=odoo16
Group=odoo16
ExecStart=/opt/odoo16/odoo-venv/bin/python3 /opt/odoo16/odoo/odoo-bin -c /etc/odoo16.conf
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

With the next command we are notifying systemd that the new file exists and reloading the daemon.

sudo systemctl daemon-reload

Next, we start the Odoo service and enable it to run on system boot.

sudo systemctl enable --now odoo16

Now we check if the service is running.

sudo systemctl status odoo16

You should get the following output.

● odoo16.service - Odoo16
     Loaded: loaded (/etc/systemd/system/odoo16.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-10-28 10:05:28 UTC; 28s ago
...

This next command will allow you to check on the messages logged by the odoo16 service.

sudo journalctl -u odoo16

Step 14: Testing the Odoo Installation

On your browser, type: http://<your_domain_or_IP_address>:8069 to access the Odoo15 instance. The Odoo 16 instance should be accessible through http://<your_domain_or_IP_address>:8070


Was this answer helpful?

« Back

Enterprise-Grade Hardware

  • Samsung
  • Juniper
  • Western Digital
  • Supermicro
  • LSI
  • Intel
  • R1Soft Backups
  • cPanel
  • MySQL
  • Parallels
  • HP Partner