Skip to Content

Odoo 17 Installation on 

U​buntu 22.04

Here is a step by step guide on installing Odoo 17 on Ubuntu 22.04. It can be used as a reference to installing other Odoo versions on other Ubuntu versions as well. However packages might differ based on the version.

  1. Login to Ubuntu Server through SSH

To set up Odoo on a remote server, you must connect to that server. This can be done using ssh. However, if you’re installing it on a local system, you can skip this step.

                         ssh username@remote_server -i ~/.ssh/id_rsa

2. Update Server Packages

Next, we need to update and upgrade packages to the newer versions. This can be done with following commands
                       
                          sudo apt update

                          sudo apt upgrade -y

3. Secure the Server

Next, we will add the security by installing openssh-server and fail2ban packages. Installing openssh-server ensures secure remote access to your server, while fail2ban adds an extra layer of protection by actively detecting and blocking potential security threats, making your server more resilient against unauthorised access attempts.

  sudo apt install openssh-server fail2ban 


4. Install Packages and Libraries

Since Odoo is built on Python, we need to install some dependencies and to proceed further with Odoo installation on the server. We can install them running the following commands

The required packages, libraries, and their versions for Odoo installation may vary depending on the Odoo and Ubuntu versions. To prevent issues during installation and operation, ensure that you install the correct versions.

sudo apt install python3-pip
sudo apt install -y git python3-venv python3-dev libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev build-essential libssl-dev libffi-dev libmysqlclient-dev libjpeg-dev libpq-dev libjpeg8-dev liblcms2-dev libblas-dev libatlas-base-dev 

sudo apt install -y npm 

sudo ln -s /usr/bin/nodejs /usr/bin/node 

sudo npm install -g less less-plugin-clean-css 

sudo apt-get install -y node-less


5. Install and Configure PostgreSQL

Odoo uses PostgreSQL as database back-end, so we need to install it. Also, we will create a PostgreSQL user named odoo17.

sudo apt install postgresql -y 

sudo su - postgres 

createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo17  

The username and password are needed on configuration file. The postgres uses a distinct system user to perform tasks.

psql

ALTER USER odoo17 WITH SUPERUSER;

\q

exit

6. Install Wkhtmltopdf

For printing-related purposes, Odoo 17 requires a wkhtmltopdf version higher than 0.12.2. Wkhtmltopdf is an open-source command line tool to render HTML data into PDF format using Qt webkit. To install wkhtmltopdf on your Ubuntu 22.04 server, follow the steps below;

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

sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb

Sometimes running the above command right throw below error as some dependencies (eg. libssl1.1 ) could not be installed. In this case, we need to install those dependent packages separately and then run above command.  
dpkg: dependency problems prevent configuration of wkhtmltox:

wkhtmltox depends on libssl1.1; however:

Package libssl1.1 is not installed.

wkhtmltox depends on xfonts-75dpi; however:

Package xfonts-75dpi is not installed.

wkhtmltox depends on xfonts-base; however:

Package xfonts-base is not installed.

If this error is not encountered, below commands can be skipped. Else run below commands to install dependencies and then wkhtmltopdf

wget <http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb>

sudo apt --fix-broken install

sudo apt install xfonts-75dpi xfonts-base

sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb


7. Create an Odoo User

We will create a new user named odoo17 with home directory /home/odoo. This prevents the security risks posed by running Odoo under the root user. You can name your user whatever you want but be careful to name same as PostgreSQL user.

sudo useradd -m -d /home/odoo -U -r -s /bin/bash odoo17

8. Install Odoo

We will clone version 17.0 from Odoo repository. This will be done with odoo17 and inside /home/odoo directory

sudo su odoo17

cd ~/home/odoo

git clone --branch=17.0 --depth=1 --single-branch <https://www.github.com/odoo/odoo>

We will install Odoo using python virtual environment. Run the below commands to create a virtual environment and connect to it

python3 -m venv odoo17-venv

source odoo17-venv/bin/activate  

Install the necessary Python packages for Odoo 17 by using the requirements.txt file located within the odoo directory.

pip3 install wheel

pip3 install -r odoo/requirements.txt

deactivate

9. Create a Directory for Custom Modules 

mkdir /home/odoo/custom_addons

This directory should later be added to the addons_path parameter that defines a list of directories where Odoo searches for modules. After this step, we will switch back from odoo user

exit

10. Setup Configuration File for Odoo

For Odoo to operate effectively, it needs specific information like the database user, password, addons locations, and more. While these details can be supplied when running Odoo via the command line, creating a configuration file streamlines the process, eliminating the need to provide them with each run.

sudo nano /etc/odoo.conf

A sample of the configuration file can be found inside the odoo folder, or you can copy the content from the section below. You can find more information about the above parameters and more here

[options]

addons_path = /home/odoo/odoo/addons,/home/odoo/odoo/addons,/home/odoo/custom_addons

data_dir = /home/odoo/.local/share/Odoo

admin_passwd = "your_admin_password"

db_host = False

db_name = False

db_filter=False

db_password = False

db_port = 5432

db_user = odoo17

list_db = True

log_db = False

log_db_level = warning

log_handler = :INFO

log_level = info

logfile = /var/log/odoo/odoo.log

Next, grant system user odoo17 access to this config file.

sudo chown odoo17: /etc/odoo.conf

sudo chmod 640 /etc/odoo.conf

Now, create a log directory for Odoo and set necessary permissions for odoo17 to access it.

sudo mkdir /var/log/odoo

sudo chown odoo17: /var/log/odoo

11. Create Odoo Service File

Next, we will create a systemd service file for Odoo which will help in start/stop/restart Odoo server

sudo nano /etc/systemd/system/odoo-server.service

Copy and paste the above content. However make sure all the information are correct in case you have made changes. 

[Unit]

Description=Odoo17

Requires=postgresql.service

After=network.target postgresql.service

[Service]

Type=simple

SyslogIdentifier=odoo17

PermissionsStartOnly=true

User=odoo17

Group=odoo17

ExecStart=/home/odoo/odoo17-venv/bin/python3 /home/odoo/odoo/odoo-bin -c /etc/odoo.conf

StandardOutput=journal+console

[Install]

WantedBy=multi-user.target

Finally, set the necessary permissions and start the Odoo server

sudo chmod 755 /etc/systemd/system/odoo-server.service

sudo chown root: /etc/systemd/system/odoo-server.service

systemctl start odoo-server.service


The above command will start the odoo-server. To check the status of the odoo-server, you can use below command.

systemctl status odoo-server.service

12. Create and Access Odoo Database

If Odoo installation was successful, status will be active. Now, you can access Odoo with the following URL. It will redirect you to database create page where you can create Odoo database

Odoo runs on port 8069 by default. However this can be configured from configuration file

http://localhost_or_ip_address:8069

You can use below command to access odoo log file.

tail -f /var/log/odoo/odoo.log  

You can use below command to stop odoo server

sudo service odoo-server stop

You can use below command to start odoo server  

sudo service odoo-server start

You can use this command to restart odoo server

sudo service odoo-server restart  


Having successfully installed Odoo 17, this guide not only serves as a reliable reference for future Odoo 17 installations but also provides insights into installing other Odoo versions. Understanding the necessary libraries and packages, and their roles, equips you with valuable knowledge for troubleshooting related issues in the future. I hope this blog has facilitated a smooth Odoo installation and deployment for you!