This article will guide you through the installation and configuration process of Odoo 16 in an Ubuntu 22.04 system.
Prerequisites
OS: Ubuntu 22.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: 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 4: Install Dependencies
Since Odoo is built on Python, we need to install some dependencies to proceed with installing Odoo 16 on our Ubuntu 22.04 system. We can install them by running this command below.
sudo apt install build-essential wget git python3-pip python3-dev python3-venv python3-wheel libfreetype6-dev libxml2-dev libzip-dev libsasl2-dev python3-setuptools libjpeg-dev zlib1g-dev libpq-dev libxslt1-dev libldap2-dev libtiff5-dev libopenjp2-7-dev
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 5. Install Wkhtmltopdf
For printing-related purposes, Odoo 16 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 apt install wkhtmltopdf
Once installed, you can check its version by running this command
wkhtmltopdf --version
You will see an output like this:
wkhtmltopdf 0.12.6
Step 6. Install Odoo
In Ubuntu 22.04, we can install Odoo from the default Ubuntu repository, but this will install Odoo version 16. In this article, we will install Odoo 16 under a python virtual environment. We created a system user earlier in this article; let’s switch to system user ‘odoo16’ and then install Odoo under that username.
sudo su - odoo16
The command above should bring you to /opt/odoo16 and log you in as user ‘odoo16’. Now, download Odoo from Github.
git clone https://www.github.com/odoo/odoo --depth 1 --branch 16.0 odoo16
Execute the following command to create a new python virtual environment.
python3 -m venv odoo16-venv
The virtual environment is now installed; it is time to activate it by running this command.
source odoo16-venv/bin/activate
Once executed, your shell prompt would look like this:
(odoo16-venv) odoo16@ubuntu22:~$
Next, let’s install Odoo
(odoo16-venv) odoo16@ubuntu22:~$ pip3 install wheel
(odoo16-venv) odoo16@ubuntu22:~$ pip3 install -r odoo16/requirements.txt
Once Odoo installation is completed, we can create a new directory to store our custom Odoo add-ons.
(odoo16-venv) odoo16@ubuntu22:~$ deactivate
Step 7: 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/odoo16/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 8: 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]
admin_passwd = admin_passwd
db_host = False
db_port = False
db_user = odoo16
db_password = False
addons_path = /opt/odoo16/odoo16/addons,/opt/odoo16/odoo16/custom-addons
xmlrpc_port = 8069
Step 9: Create Odoo Systemd Unit file
In this step, we will create a systemd unit file. It is required to start/stop/restart Odoo.
sudo nano /etc/systemd/system/odoo16.service
Paste the following content into the systemd unit file above.
[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/odoo16-venv/bin/python3 /opt/odoo16/odoo16/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 10: 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 22.04