YouTube Icon

Code Playground.

How to Install Odoo 13 on Ubuntu 18.04

CFG

How to Install Odoo 13 on Ubuntu 18.04

Odoo is a famous open-source suite of enterprise apps. It offers a number applications, which includes CRM, e-Commerce, website builder, billing, accounting, production, warehouse, challenge management, stock, and lots extra, all seamlessly included.

Odoo can be established in a couple of ways depending on the use case and available technology. The easiest and quickest way to install Odoo is by means of using the reputable Odoo APT repositories.

Installing Odoo in a digital surroundings, or deploying as a Docker field, permits you to have greater manipulate over the machine’s installation, and run multiple Odoo versions at the identical gadget.

In this manual, we can walk you through installing and deploying Odoo thirteen internal a Python digital surroundings on Ubuntu 18.04. We’ll download Odoo from their Github repository and use Nginx as a reverse proxy.

Installing Prerequisites
Login to your Ubuntu as a sudo user and replace the Apt cache:

sudo apt update


Install Git , Pip , Node.Js , and the equipment required to construct Odoo dependencies:

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

Creating a System User
Create a system user in order to run Odoo, named odoo13 with home listing /opt/odoo13:

sudo useradd -m -d /opt/odoo13 -U -r -s /bin/bash odoo13

You can set the call of the user to some thing you want, as lengthy you create a PostgreSQL user with the same call.

Installing and Configuring PostgreSQL
Odoo makes use of PostgreSQL as the database again-cease. To deploy PostgreSQL run the following command:

sudo apt install postgresql


Once the set up is completed, create a PostgreSQL user with the same call as the previously created device user, in our case that is odoo13:

sudo su - postgres -c "createuser -s odoo13"

Installing Wkhtmltopdf
The wkhtmltox package provides a hard and fast of open-source command-line equipment that could render HTML into PDF and numerous photo formats. To be able to print PDF reports, you’ll need to put in the wkhtmltopdf device. The recommended model for Odoo is zero.12.5, which isn't always available in the default Ubuntu 18.04 repositories.

Download the package the use of the following wget command:

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb

Once the download is entire, install the bundle through typing:

sudo apt install ./wkhtmltox_0.12.5-1.bionic_amd64.deb

Installing and Configuring Odoo 13
As cited before, we’ll set up Odoo from the source inside an isolated Python digital environment .

First, alternate to consumer “odoo13”:

sudo su - odoo13


Clone the Odoo thirteen source code from GitHub:

git clone https://www.github.com/odoo/odoo --depth 1 --branch 13.0 /opt/odoo13/odoo

Once the down load is complete, create a brand new Python digital surroundings for Odoo:

cd /opt/odoo13
python3 -m venv odoo-venv


Activate the environment with the subsequent command:

source odoo-venv/bin/activate


Install all required Python modules with pip3:

pip3 install wheel
pip3 install -r odoo/requirements.txt


If you come upon any compilation blunders in the course of the installation, make certain all the required dependencies listed within the Installing Prerequisites segment are set up.
Once finished, deactivate the environment by using typing:

deactivate


We’ll create a brand new directory that will maintain the third birthday celebration addons.

mkdir /opt/odoo13/odoo-custom-addons


Later, we’ll add this listing to the addons_path parameter. This parameter defines a listing of directories wherein Odoo searches for modules.
Switch back to your sudo user:

exit

Create a configuration document with the following content:

sudo nano /etc/odoo13.conf

/etc/odoo13.conf

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

Do now not overlook to change the my_admin_passwd to some thing greater relaxed.
Creating a Systemd Unit File
Open your textual content editor and create a provider unit report known as odoo13.Carrier with the subsequent content:

sudo nano /etc/systemd/system/odoo13.service

/etc/systemd/system/odoo13.service

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

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

[Install]
WantedBy=multi-user.target

Notify systemd that a brand new unit file exists:

sudo systemctl daemon-reload


Start the Odoo carrier and enabled it to begin on boot by using jogging:

sudo systemctl enable --now odoo13


Verify the carrier fame:

sudo systemctl status odoo13


The output should appearance some thing like beneath, indicating that the Odoo service is lively and going for walks.

? odoo13.service
   Loaded: loaded (/etc/systemd/system/odoo13.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-10-19 20:06:23 UTC; 3s ago
 Main PID: 1860 (python3)
    Tasks: 4 (limit: 2362)
   CGroup: /system.slice/odoo13.service
           ??1860 /opt/odoo13/odoo-venv/bin/python3 /opt/odoo13/odoo/odoo-bin -c /etc/odoo13.conf


To see the messages logged by means of the Odoo provider, use the command below:

sudo journalctl -u odoo13

Testing the Installation
Open your browser and kind: http://<your_domain_or_IP_address>:8069

Assuming the installation is successful, a display screen similar to the subsequent will appear:

Configuring Nginx as SSL Termination Proxy
The default Odoo net server is serving site visitors over HTTP. To make the Odoo deployment greater secure we can configure Nginx as an SSL termination proxy so one can serve the traffic over HTTPS.

SSL termination proxy is a proxy server that handles the SSL encryption/decryption. This approach that the termination proxy (Nginx) will method and decrypt incoming TLS connections (HTTPS), and skip on the unencrypted requests to the internal carrier (Odoo). The site visitors among Nginx and Odoo will now not be encrypted (HTTP).

Using a reverse proxy gives you a whole lot of blessings along with Load Balancing, SSL Termination, Caching, Compression, Serving Static Content, and greater.

Ensure which you have met the subsequent conditions before persevering with with this phase:

Domain call pointing to your public server IP. We’ll use example.Com.
Nginx installed .
SSL certificate to your area. You can installation a unfastened Let’s Encrypt SSL certificates .
Open your text editor and create/edit the domain server block:

sudo nano /etc/nginx/sites-enabled/example.com


The following configuration units up SSL Termination, HTTP to HTTPS redirection , WWW to non-WWW redirection, cache the static files, and allow GZip compression.

/etc/nginx/sites-enabled/example.com

# Odoo servers
upstream odoo {
 server 127.0.0.1:8069;
}

upstream odoochat {
 server 127.0.0.1:8072;
}

# HTTP -> HTTPS
server {
    listen 80;
    server_name www.example.com example.com;

    include snippets/letsencrypt.conf;
    return 301 https://example.com$request_uri;
}

# WWW -> NON WWW
server {
    listen 443 ssl http2;
    server_name www.example.com;

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
    include snippets/ssl.conf;
    include snippets/letsencrypt.conf;

    return 301 https://example.com$request_uri;
}

server {
    listen 443 ssl http2;
    server_name example.com;

    proxy_read_timeout 720s;
    proxy_connect_timeout 720s;
    proxy_send_timeout 720s;

    # Proxy headers
    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;

    # SSL parameters
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
    include snippets/ssl.conf;
    include snippets/letsencrypt.conf;

    # log files
    access_log /var/log/nginx/odoo.access.log;
    error_log /var/log/nginx/odoo.error.log;

    # Handle longpoll requests
    location /longpolling {
        proxy_pass http://odoochat;
    }

    # Handle / requests
    location / {
       proxy_redirect off;
       proxy_pass http://odoo;
    }

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

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

Don’t overlook to update example.Com along with your Odoo area and set the best route to the SSL certificate documents. The snippets used on this configuration are created on this manual .
Once you’re done, restart the Nginx service :

/etc/odoo13.conf

proxy_mode = True


Next, we need to inform Odoo to apply the proxy. To do so, open the configuration document and upload the following line:

/etc/odoo13.conf
proxy_mode = True


Restart the Odoo service for the modifications to take effect:

sudo systemctl restart odoo13

At this factor, the reverse proxy is configured, and you may get right of entry to your Odoo example at: https://instance.Com

Changing the Binding Interface
This step is optionally available, but it is a great protection exercise.

By default, Odoo server listens to port 8069 on all interfaces. To disable direct get admission to to the Odoo instance, you may both block the port 8069 for all public interfaces or pressure Odoo to pay attention only at the nearby interface.

We’ll configure Odoo to listen most effective on 127.0.0.1. Open the configuration add the subsequent two strains on the end of the file:

/etc/odoo13.conf

xmlrpc_interface = 127.0.0.1
netrpc_interface = 127.0.0.1


Save the configuration report and restart the Odoo server for the changes to take effect:

sudo systemctl restart odoo13

Enabling Multiprocessing
By default, Odoo is operating in multithreading mode. For production deployments, it's miles encouraged to exchange to the multiprocessing server because it will increase stability, and make higher usage of the system sources.

To permit multiprocessing you want to edit the Odoo configuration and set a non-zero range of worker processes. The number of workers is calculated based totally at the range of CPU cores within the machine and the available RAM memory.

According to the authentic Odoo documentation to calculate the workers' variety and required RAM memory length, you could use the subsequent formulation and assumptions:

Worker wide variety calculation

Theoretical maximal range of employee = (system_cpus * 2) + 1
1 worker can serve ~= 6 concurrent customers
Cron people additionally require CPU
RAM reminiscence size calculation

We will take into account that 20% of all requests are heavy requests, and 80% are lighter ones. Heavy requests are the use of round 1 GB of RAM while the lighter ones are the usage of round one hundred fifty MB of RAM
Needed RAM = number_of_workers * ( (light_worker_ratio * light_worker_ram_estimation) + (heavy_worker_ratio * heavy_worker_ram_estimation) )
If you do no longer realize what number of CPUs you have got in your system, use the subsequent grep command:

grep -c ^processor /proc/cpuinfo


Let’s say you have got a device with four CPU cores, 8 GB of RAM memory, and 30 concurrent Odoo users.

30 users / 6 = **5** (5 is theoretical range of employees wanted )
(4 * 2) + 1 = **nine** ( 9 is the theoretical most quantity of employees)
Based at the calculation above, you may use five people + 1 worker for the cron employee that could be a total of 6 people.

Calculate the RAM reminiscence consumption based totally at the number of employees:

RAM = 6 * ((0.8*one hundred fifty) + (zero.2*1024)) ~= 2 GB of RAM
The calculation shows that the Odoo set up will need around 2GB of RAM.

To transfer to multiprocessing mode, open the configuration report and append the calculated values:

/etc/odoo13.conf

limit_memory_hard = 2684354560
limit_memory_soft = 2147483648
limit_request = 8192
limit_time_cpu = 600
limit_time_real = 1200
max_cron_threads = 1
workers = 5

Restart the Odoo service for the changes to take effect:

sudo systemctl restart odoo13

The relaxation of the device sources can be utilized by other offerings that run on this machine. In this manual, we mounted Odoo together with PostgreSQL and Nginx at the same server. Depending for your set up you may also have other offerings walking for your server.

Conclusion
This academic walked you through the set up of Odoo thirteen on Ubuntu 18.04 in a Python virtual surroundings using Nginx as a opposite proxy. We’ve additionally proven you a way to permit multiprocessing and optimize Odoo for a production environment.

You may also want to test our tutorial approximately the way to create automated each day backups of Odoo databases .

If you've got questions, experience unfastened to go away a remark beneath.




CFG