Knowledgebase

Question About Servers

How to Install Odoo 17 on Ubuntu 18.04 Print

  • 0

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

Prerequisites

OS: Ubuntu 18.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 and Install Python3.10

Ubuntu 18.04 comes with Python3.6 by default. Odoo17 requires Python3.10. So we need to install the required version first.

Make sure your system is updated:

sudo apt update && sudo apt upgrade

Install required dependencies:

sudo apt install wget build-essential libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev

Download the archive from Python’s official site:

wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz 

Extract the archive:

tar xzf Python-3.10.0.tgz

Move to extracted directory:

cd Python-3.10.0 

Compile on your system

./configure --enable-optimizations 

Finally, install it on your system, make sure you are using altinstall command since this might replace your current Python version if you don’t use this command:

make altinstall

If that is successfully installed you can check the Python version:

python3.10 -V

or 

python3.10 --version

We need to specify Python3.10 as the preferred Python version for this system. Follow these steps to change the default Python version from Python3.8 to Python3.10.

First, you must create symbolic links for each Python version installed on your system. When creating the symbolic link, you should include the group name “python3” followed by the version number. To do this, use the commands below:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2

To view the available Python versions, you can use the following command:

sudo update-alternatives --config python3

You will see an output similar to the one below:

There are 2 choices for the alternative python3 (providing /usr/bin/python3).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.10   1         auto mode
  1            /usr/bin/python3.10   1         manual mode
  2            /usr/bin/python3.6    2         manual mode

Press <enter> to keep the current choice[*], or type selection number:

You must enter the corresponding selection number to set a different version of Python as the default, such as Python 3.10. The selection number may vary based on the number of Python versions installed on your system.

To switch to Python 3.10, enter the number 1. Upon successful completion, you should expect to see the following output:

update-alternatives: using /usr/bin/python3.10 to provide /usr/bin/python3 (python3) in manual mode

Now you need to close this terminal window and start another one for the changes to take effect. Log in to the VPS again via SSH and proceed to step 3 below.

Step 3: Create an Odoo user.

Create a new user called odoo17 with home directory /opt/odoo17. 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/odoo17 -U -r -s /bin/bash odoo17

Step 4: Install Dependencies

Since Odoo is built on Python, we need to install some dependencies to proceed with installing Odoo 17 on our Ubuntu 20.04 system. We can install them by running the commands below.

sudo apt install -y git python3-pip python-dev 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

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 to handle 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 odoo17

sudo su - postgres

createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo17
The user and the password are needed for the conf file. Postgres uses a distinct system user to perform tasks. To switch between users, run sudo su -postgres. Next, create a database user for Odoo 17.
psql
ALTER USER odoo17 WITH SUPERUSER;
If the user runs the command above, superuser access rights will be guaranteed. Next, log out of Postgres and PSQL.
\q
exit

Step 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 18.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

sudo apt install -f

Step 7: Install Odoo

In Ubuntu 18.04, we can install Odoo from the default Ubuntu repository, but this will install Odoo version 17. In this article, we will install Odoo 17 in a python virtual environment. We created a system user earlier in this article; let’s switch to system user ‘odoo17’ and then install Odoo under that username.

sudo su - odoo17

The command above should bring you to /opt/odoo17 and log you in as user ‘odoo17’. Now, download Odoo from Github.

git clone https://www.github.com/odoo/odoo --depth 1 --branch 17.0 odoo17

Execute the following command to create a new python virtual environment.

python3 -m venv odoo17-venv

The virtual environment is now installed; it is time to activate it by running this command.

source odoo17-venv/bin/activate

Once executed, your shell prompt would look like this:

(odoo17-venv) odoo17@ubuntu18:~$

Next, let’s install Odoo

(odoo17-venv) odoo17@ubuntu18:~$ pip3 install wheel
(odoo17-venv) odoo17@ubuntu18:~$ pip3 install -r odoo17/requirements.txt

Once Odoo installation is completed, we can create a new directory to store our custom Odoo add-ons.

(odoo17-venv) odoo17@ubuntu18:~$ deactivate

Step 8: Create a directory for the 3rd party addons:

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

mkdir /opt/odoo17/odoo17/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 to the sudo user using this command.

exit

Step 9: Create a configuration file for the Odoo Installation

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

sudo nano /etc/odoo17.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 = odoo17
db_password = False
addons_path = /opt/odoo17/odoo17/addons,/opt/odoo17/odoo17/custom-addons
xmlrpc_port = 8069

Step 10: 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/odoo17.service

Paste the following content into the systemd unit file above.

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

[Service]
Type=simple
SyslogIdentifier=odoo17
PermissionsStartOnly=true
User=odoo17
Group=odoo17
ExecStart=/opt/odoo17/odoo17-venv/bin/python3 /opt/odoo17/odoo17/odoo-bin -c /etc/odoo17.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 odoo17

Now we check if the service is running.

sudo systemctl status odoo17

You should get the following output.

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

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

sudo journalctl -u odoo17

Step 11: 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 17. 

Congratulations! You have successfully installed Odoo 17 on Ubuntu 18.04


Was this answer helpful?

« Back

Enterprise-Grade Hardware

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