How to Install Odoo 12 on Debian 10 with Nginx as a Reverse Proxy

In this guide, we will show you how to install Odoo 12 with Nginx as a reverse proxy on a Debian 10 VPS.

Odoo, also known as OpenERP, is a free and open-source ERP platform. It’s one of the most popular ERP platforms available thanks to its customizability and flexibility. Written in the Python programming language, Odoo is used for many business applications, including sales pipeline, project management, CRM, invoicing, accounting, inventory, and much more. Odoo also provides 10,000+ modules that cover all of your business needs in a one-stop solution. It supports many operating systems including Linux, Windows, and macOS.

You can install Odoo in several ways, such as using their official repositories, using an install script, using Docker or Docker Compose, and using a virtual environment. You can also run multiple Odoo instances in a single server with Docker or in a virtual environment. This makes everything quite flexible, allowing Odoo to conform to your needs.

Installing Odoo 12 on Debian 10 should take less than 10 minutes to complete. Let’s get started with the tutorial.

Prerequisites

  • A Debian 10 VPS with root access enabled, or a user with sudo privileges.
  • Minimum 2GB of RAM and 2 CPU cores to run 5 users. We’ll be using our SSD 2 VPS plan.
  • A valid domain name pointed with your VPS IP address. In this tutorial, we will use example.com as domain name.

Step 1: Log in via SSH and Update Packages

Log in to your Debian 10 VPS with SSH as the root user:

ssh [email protected]IP_Address -p Port_number

Replace “root” with a user that has sudo privileges if necessary. Additionally, replace “IP_Address” and “Port_Number” with your server’s respective IP address and SSH port number. Next, let’s make sure that we’re on Debian 10. You can do that like this:

# lsb_release -a

You should get this as the output:

Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

Then, run the following command to make sure that all installed packages on the server are updated to their latest available versions:

# apt update && apt upgrade

Step 2: Install Odoo 12 Dependencies

Before starting, we will need to install some dependencies required to install Odoo 12. You can install all the dependencies by running the following command:

apt-get install git wget build-essential node-less libjpeg-dev libpq-dev python3-pip python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools

Step 3: Install wkhtmltopdf

In order to render HTML into PDF and various image formats, we will need to install the wkhtmltopdf tool. You can download the wkhtmltopdf package with the following command:

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

Once downloaded, extract and install the downloaded package using the following command:

tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
mv wkhtmltox/bin/wkhtmlto* /usr/bin/
ln -nfs /usr/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf

Step 4: Create a System User

Next, we will need to create a new system user to run Odoo. You can create a new user with named odoo12 with the home directory set to /opt/odoo12 using the following command:

useradd -m -d /opt/odoo12 -U -r -s /bin/bash odoo12

Step 5: Install PostgreSQL

Odoo uses a PostgreSQL database to store its information so we have to install and use the PostgreSQL service.

You can run the following command to install PostgreSQL server:

apt-get install postgresql

After installing PostgreSQL, create a PostgreSQL user with the same name as the new system user. Run the following command to create a PostgreSQL user:

su - postgres -c "createuser -s odoo12"

Step 6: Install and Configure Odoo 12

In this section, we will download Odoo 12 from the Git repository and install it in a Python virtual environment.

First, log in as odoo12 user and download Odoo 12 from the Git repository:

su - odoo12
git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 odoo

Once the download is complete, create a new Python virtual environment for the Odoo 12 installation with the following command:

python3 -m venv odoo-venv

Next, activate the virtual environment with the following command:

[email protected]:~$ source odoo-venv/bin/activate

You should get the following output:

(odoo-venv) [email protected]:~$

Next, install the required modules using the pip3 command as shown below:

(odoo-venv) [email protected]:~$ pip3 install wheel
(odoo-venv) [email protected]:~$ pip3 install -r odoo/requirements.txt

Once all the required modules are installed successfully, deactivate the virtual environment with the following command:

(odoo-venv) [email protected]:~$ deactivate

Next, create a separate directory for Odoo 12 custom addons:

mkdir /opt/odoo12/odoo-custom-addons

Next, exit from the odoo12 user with the following command:

exit

Next, we will need to create a configuration file for the Odoo 12 instance. You can copy the sample configuration file with the following command:

cp /opt/odoo12/odoo/debian/odoo.conf /etc/odoo12.conf

Next, open the file /etc/odoo12.conf with nano editor:

nano /etc/odoo12.conf

Make the following changes:

[options]
; This is the password that allows database operations:
admin_passwd = password
db_host = False
db_port = False
db_user = odoo12
db_password = False
xmlrpc_port = 8069
addons_path = /opt/odoo12/odoo/addons,/opt/odoo12/odoo-custom-addons

Note : replace ‘password‘ with a strong password, odoo12 with the Odoo system user and 8069 with the port you want to run Odoo on. It is necessary if you want to run multiple Odoo instances on the same server.

Next, change the ownership of /etc/odoo12.conf to odoo12:

chown odoo12:odoo12 /etc/odoo12.conf

Step 7: Create a Systemd Service File for Odoo 12

Next, we will need to create a systemd service file to manage Odoo 12 service. You can create it in the /etc/systemd/system/ directory:

nano /etc/systemd/system/odoo12.service

Add the following lines:

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

[Service]
Type=simple
SyslogIdentifier=odoo12
PermissionsStartOnly=true
User=odoo12
Group=odoo12
ExecStart=/opt/odoo12/odoo-venv/bin/python3 /opt/odoo12/odoo/odoo-bin -c /etc/odoo12.conf
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

Note : Change User and Group with the Odoo system user if it differs from our example user.

Save and close the file. Then, reload the systemd daemon with the following command:

systemctl daemon-reload

Next, start the newly-created odoo12 service and enable it to start after system reboot with the following command:

systemctl start odoo12
systemctl enable odoo12

You can now verify the status of Odoo service with the following command:

systemctl status odoo12

You should get the following output:

● odoo12.service - Odoo12
Loaded: loaded (/etc/systemd/system/odoo12.service; disabled; vendor preset: enabled)
Active: active (running) since Sun 2019-08-25 11:48:40 EDT; 7s ago
Main PID: 13043 (python3)
Tasks: 2 (limit: 1138)
Memory: 63.8M
CGroup: /system.slice/odoo12.service
├─13043 /opt/odoo12/odoo-venv/bin/python3 /opt/odoo12/odoo/odoo-bin -c /etc/odoo12.conf
└─13046 /usr/local/bin/wkhtmltopdf --version

Aug 25 11:48:40 debian systemd[1]: Started Odoo12.
Aug 25 11:48:46 debian odoo12[13043]: 2019-08-25 15:48:46,062 13043 INFO ? odoo: Odoo version 12.0
Aug 25 11:48:46 debian odoo12[13043]: 2019-08-25 15:48:46,065 13043 INFO ? odoo: Using configuration file at /etc/odoo12.conf
Aug 25 11:48:46 debian odoo12[13043]: 2019-08-25 15:48:46,073 13043 INFO ? odoo: addons paths: ['/opt/odoo12/.local/share/Odoo/addons/12.0', '/
Aug 25 11:48:46 debian odoo12[13043]: 2019-08-25 15:48:46,074 13043 INFO ? odoo: database: [email protected]:default
Aug 25 11:48:47 debian odoo12[13043]: 2019-08-25 15:48:47,600 13043 INFO ? odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf

You can also verify the Odoo listening port using the following command:

netstat -plntu | grep 8069

You should get the output one below:

tcp 0 0 0.0.0.0:8069 0.0.0.0:* LISTEN 13208/python3

Step 8: Install and Configure Nginx as a Reverse Proxy

Next, we will need to configure Nginx as a reverse proxy to forward request coming on port 80 to the Odoo 12 instance that is listening on port 8069. You can get a lot of benefits, including load balancing, caching, compression, and serving static content using a reverse proxy.

First, install Nginx with the following command:

apt-get install nginx

Once installed, create a new Nginx virtual host file with the following command:

nano /etc/nginx/sites-available/example.com

Add the following lines:

upstream odoo {
server 127.0.0.1:8069;
}
server {
listen 80;
server_name example.com;

access_log /var/log/nginx/odoo12.access.log;
error_log /var/log/nginx/odoo12.error.log;

location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;

proxy_redirect off;
proxy_pass http://odoo;
}

location ~* /web/static/ {
proxy_cache_valid 200 90m;
proxy_buffering on;
expires 864000;
proxy_pass http://odoo;
}

gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
}

Make sure to replace example.com with your registered domain name.

Save and close the file. Then check Nginx for any syntax errors with the following command:

nginx -t

You should get the following output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Next, enable the Nginx virtual host and restart Nginx service to apply the configuration changes:

ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
systemctl restart nginx

Step 9: Access Odoo 12 Instance

Odoo 12 is now installed and configured. Next, open your web browser and type the URL http://example.com. You will be redirected to the Odoo 12 web interface:

odoo 12

Now, provide Odoo master password (which you set in the file /etc/odoo12.conf), Odoo database name, Email, Password, Country, Select Demo data and click on the Create database button. You will be redirected to the Odoo 12 default dashboard as shown below:

odoo 12 back-end

That’s it. You have successfully install Odoo 12 with Nginx as a reverse proxy on a Debian 10 VPS. At this point, you can install various plugins like invoicing, accounting, inventory, and many more based on your business needs.


Of course, you don’t have to know how to install Odoo 12 on Debian 10 if you have an Odoo VPS Hosting plan with us. You can simply ask our administrators to install Odoo 12 on Debian 10 for you. They’re available 24/7 and will be able to help you with the installation of Odoo 12 on Debian 10.

PS. If you enjoyed reading this blog post on how to Install Odoo 12 on Debian 10, or if you found the tutorial helpful, feel free to share it on social networks using the shortcuts below, or simply leave a comment. Thanks.

2 thoughts on “How to Install Odoo 12 on Debian 10 with Nginx as a Reverse Proxy”

  1. This post must be modified to include:
    workers calculus and addition.
    ssl certificate addition and autoupgrade.

    • Those are additional options and personal preference. This tutorial helps you with installing basic Odoo 12 instance.

Leave a Comment

To prove you are human please solve the following *