Knowledgebase

Question About Servers

How to Install Odoo 16 on Ubuntu 20.04 Print

  • 1

This article will guide you through the installation and configuration process of Odoo 16 in an Ubuntu 20.04 system.

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 root@127.0.0.1 -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: In Ubuntu, create an Odoo user.

Create a new user called odoo16 with home directory /opt/odoo16. This prevents the security risks posed by running odoo under the root user. You can do it with this command. You can give any name to the user. However, be careful to create a PostgreSQL user with the same name.

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 a PostgreSQL user for the handling of the database server i.e. PostgreSQL.  In our case, we will create a PostgreSQL user with the same name as the previously created system user i.e odoo16

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

Step 6: Installing wkhtmltopdf

Wkhtmltopdf is the package that allows Odoo 16 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: Installing and Configuring Odoo 16

First, we'll change the user to the one we created i.e odoo16.

sudo su - odoo16

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

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

Step 8: Install Odoo Dependencies

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: Create a directory for the 3rd party addons

We’ll create a new directory a separate directory for the 3rd party addons.

mkdir /opt/odoo16/odoo-custom-addons

This directory 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 10: Create a configuration file for the Odoo Installation

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.

[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 = 8069
logfile = /var/log/odoo16/odoo.log
logrotate = True
addons_path = /opt/odoo16/odoo/addons,/opt/odoo16/odoo-custom-addons

Step 11: Creating Systemd Unit File

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-2-28 09:56: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 12: Testing the Odoo Installation

On your browser, type: http://<your_domain_or_IP_address>:8069

If the installation was successful, you'll see the start page for Odoo 16. 

Congratulations! You have successfully installed Odoo 16 on Ubuntu 20.04


Was this answer helpful?

« Back

Enterprise-Grade Hardware

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