Créer une instance Odoo16 sur Debian

Prérequis

  • Ubuntu 22.04 VPS.
  • Au moins 2GB de RAM.
  • Acces SSH en sudo

Step 1. Update The System

ssh user@IP_Address [ -p Port_number ]

MaJ systeme :

$ su
# apt update && apt upgrade

Step 2. Add System User

We will install an Odoo 16 instance under a system user account. So, we need to create a new system account. This command below is used to create a user called “odoo16”.

# useradd -m -d /opt/odoo16 -U -r -s /bin/bash odoo16

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

# 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 libffi-dev

# apt-get install 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

Ajouter les dépendances WEB :

# apt-get install -y npm
# ln -s /usr/bin/nodejs /usr/bin/node
# npm install -g less less-plugin-clean-css
# apt-get install -y node-less

Step 4. Install PostgreSQL

Odoo only supports PostgreSQL to store its data. Let’s execute the command below to install the PostgreSQL server on our Ubuntu 22.04 server.

# apt install postgresql

After the installation is finished, we can add a new postgresql user for our Odoo 16; run this command:

# 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-get install libqt5webkit5
sudo apt-get install wkhtmltopdf

Once installed, you can check its version by running this command

$ wkhtmltopdf --version

La version installée doit être la suivante :

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 14. 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 /opt/odoo16/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 --upgrade pip
(odoo16-venv) odoo16@ubuntu22:~$ pip3 install wheel
(odoo16-venv) odoo16@ubuntu22:~$ pip3 install xlwt
(odoo16-venv) odoo16@ubuntu22:~$ pip3 install num2words
(odoo16-venv) odoo16@ubuntu22:~$ pip3 install pypdf2
(odoo16-venv) odoo16@ubuntu22:~$ pip3 install psycopg2-binary
(odoo16-venv) odoo16@ubuntu22:~$ pip3 install -r odoo16/requirements.txt

si on a des erreurs, alors installer manuellement :
37 pip3 install psycopg
38 pip3 install psycopg2
49 pip3 install pypdf2
58 pip3 install psycopg2-binary
67 pip3 install setuptools
68 pip3 install --upgrade pip setuptools wheel
73 pip3 install passlib
76 while read requirement; do pip3 install $requirement; done < requirements.odoo16
83 pip3 install mail
85 pip3 install lxml_html_clean
88 pip3 install werkzeug
91 pip3 install werkzeug==2.0.2

Avec : more requirements.odoo16

Babel
decorator
docutils
gevent
greenlet
Jinja2
lxml
Mako
MarkupSafe
num2words
ofxparse
passlib
Pillow
psutil
psycopg2
pydot
pyopenssl
PyPDF2
pyserial
python-dateutil
pytz
pyusb
qrcode
reportlab
requests
zeep
vobject
Werkzeug
XlsxWriter
xlwt
xlrd

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

(odoo16-venv) odoo16@ubuntu22:~$ deactivate
$ mkdir /opt/odoo16/odoo16/custom-addons

Now, exit from user ‘odoo16’ and create the Odoo configuration file.

Configurer Odoo : Fichier .conf

chown -R odoo16:odoo16 /opt/odoo16/

Créer + Changer propriétaire du fichier de log

exit
sudo touch /var/log/odoo16.log
sudo chown odoo16:odoo16 /var/log/odoo16.log
$ sudo nano /etc/odoo16.conf

Paste the following contents into the file.

[options]
admin_passwd = cmebdc
db_host = False
db_port = False
db_user = odoo16
db_password = False
addons_path = /opt/odoo16/odoo16/addons,/opt/odoo16/odoo16/custom-addons
logfile = /var/log/odoo16.log
xmlrpc_port = 8016

Make sure to modify the value of the m0d1fyth15 key above and use a stronger password. This is your Odoo master password; you need it to create or delete databases.

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

That’s it. We can now reload systemd and run Odoo.

$ sudo systemctl daemon-reload
$ sudo systemctl start odoo16

Check if Odoo is starting by running this command:

$ sudo systemctl status odoo16

Open your web browser and navigate to http://YOUR_SERVER_IP_ADDRESS:8069; you will see the Odoo page.

Retour en haut