Installing Prerequisites
The following command installs Git , Pip , Node.js , and the Odoo dependencies:
sudo apt update
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
Creating a System User
Running Odoo under the root user is not allowed, as it is a security risk. We’ll create a new system user and group with home directory /opt/odoo14
that will run the Odoo service. To do so, enter the following command:
sudo useradd -m -d /opt/odoo14 -U -r -s /bin/bash odoo14
You can name the user anything you want, as long you create a PostgreSQL user with the same name.
Installing and Configuring PostgreSQL
Odoo uses PostgreSQL as the database back-end. PostgreSQL is included in the standard Ubuntu repositories. To install it, run:
sudo apt install postgresql
When the installation is completed, create a PostgreSQL user with the same name as the previously created system user. In this example, that is odoo14
:
sudo su - postgres -c "createuser -s odoo14"
Installing wkhtmltopdf
wkhtmltopdf is a set of open-source command-line tools for rendering HTML pages into PDF and various image formats. To print PDF reports in Odoo, you’ll need to install the wkhtmltox
package. The recommended version for Odoo is version 0.12.5
, which can be download from Github:
sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
Once the file is downloaded, install it by typing:
sudo apt install ./wkhtmltox_0.12.5-1.bionic_amd64.deb
Installing and Configuring Odoo 14
We’ll install Odoo from the source inside an isolated Python virtual environment
First, change to user “odoo14”:
sudo su - odoo14
Clone the Odoo 14 source code from GitHub:
git clone https://www.github.com/odoo/odoo --depth 1 --branch 14.0 /opt/odoo14/odoo
Create a new Python virtual environment for Odoo:
cd /opt/odoo14
python3 -m venv odoo-venv
Activate the virtual environment:
source odoo-venv/bin/activate
Install all required Python modules with pip3:
pip3 install wheel
pip3 install -r odoo/requirements.txt
Installing Prerequisites
section are installed.Once done, deactivate the environment by typing:
deactivate
that will contain the 3rd party addons:
mkdir /opt/odoo14/odoo-custom-addons
We’ll add this directory to the addons_path
parameter. This parameter defines a list of directories where Odoo searches for modules.
Switch back to your sudo user:
exit
Create a configuration file with the following content:
sudo nano /etc/odoo14.conf
[options]
; This is the password that allows database operations:
admin_passwd = my_admin_passwd
db_host = False
db_port = False
db_user = odoo14
db_password = False
addons_path = /opt/odoo14/odoo/addons,/opt/odoo14/odoo-custom-addons
my_admin_passwd
to something more secure.Creating Systemd Unit File
Open your text editor and create a service unit file called odoo14.service
with the following content:
sudo nano /etc/systemd/system/odoo14.service
[Unit]
Description=Odoo14
Requires=postgresql.service
After=network.target postgresql.service
[Service]
Type=simple
SyslogIdentifier=odoo14
PermissionsStartOnly=true
User=odoo14
Group=odoo14
ExecStart=/opt/odoo14/odoo-venv/bin/python3 /opt/odoo14/odoo/odoo-bin -c /etc/odoo14.conf
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target
Notify systemd that a new unit file exists:
sudo systemctl daemon-reload
Start the Odoo service and enable it to start on boot by running:
sudo systemctl enable --now odoo14
Verify the service status:
sudo systemctl status odoo14
The output should look something like below, showing that the Odoo service is active and running:
● odoo14.service - Odoo14
Loaded: loaded (/etc/systemd/system/odoo14.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-10-16 19:05:32 UTC; 3s ago
...
To see the messages logged by the Odoo service, use the command below:
sudo journalctl -u odoo14