Odoo (Using Sudo)

Deploy Odoo 15 on Ubuntu 20.04

Odoo is a pop open-source suite of business apps that assist companies to manage and run their business organisation. It includes a wide range of applications such as CRM, eastward-Commerce, website architect, billing, accounting, manufacturing, warehouse, project management, inventory, and much more, all seamlessly integrated.

Odoo can be installed in different means, depending on the use case and available technologies. The easiest and quickest way to install Odoo is by using the official Odoo APT repositories.

Installing Odoo in a virtual environs, or deploying as a Docker container, gives you more control over the application and allows you to run multiple Odoo instances on the same system.

This article goes through installing and deploying Odoo 15 inside a Python virtual environment on Ubuntu 20.04. We'll download Odoo from the official GitHub repository and use Nginx as a reverse proxy.

Installing Dependencies

The first step is to install Git , Pip , Node.js , and development [tools required to build](https://linuxize.com/post/how-to-install-gcc-on-ubuntu-20-04/ Odoo dependencies:

sudo apt update
sudo apt install git python3-pip build-essential wget python3-dev python3-venv \
          python3-bicycle 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 poses a dandy security run a risk. We'll create a new arrangement user and group with dwelling house directory

/opt/odoo15

that will run the Odoo service. To practise so, run the following control:

sudo useradd -one thousand -d /opt/odoo15 -U -r -southward /bin/bash odoo15

You tin can name the user anything yous want, as long you create a PostgreSQL user with the aforementioned name.

Installing and Configuring PostgreSQL

Odoo uses PostgreSQL every bit the database back-end. PostgreSQL is included in the standard Ubuntu repositories. The installation is straightforward:

sudo apt install postgresql

In one case the service is installed, create a PostgreSQL user with the same proper noun as the previously created system user. In this example, that is

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

Installing wkhtmltopdf

wkhtmltopdf is a set of open-source command-line tools for rendering HTML pages into PDF and diverse image formats. To print PDF reports in Odoo, you'll need to install the

wkhtmltox

parcel.

The version of wkhtmltopdf that is included in Ubuntu repositories does not support headers and footers. The recommended version for Odoo is version

0.12.five

. Nosotros'll download and install the parcel from Github:

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

Once the file is downloaded, install it past typing:

sudo apt install ./wkhtmltox_0.12.v-1.bionic_amd64.deb

Installing and Configuring Odoo xv

We'll install Odoo from the source inside an isolated Python virtual environs .

First, alter to user "odoo15":

sudo su - odoo15

Clone the Odoo 15 source code from GitHub:

git clone https://world wide web.github.com/odoo/odoo --depth 1 --branch 15.0 /opt/odoo15/odoo

Create a new Python virtual environment for Odoo:

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

Activate the virtual environs:

source odoo-venv/bin/activate

Odoo dependencies are specified in the requirements.txt file. Install all required Python modules with pip3:

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

If you encounter any compilation error during the installation, make sure all required dependencies listed in the

Installing Prerequisites

section are installed.

One time done, deactivate the surroundings by typing:

conciliate

We'll create a new directory a split up directory for the 3rd party addons:

mkdir /opt/odoo15/odoo-custom-addons

Later nosotros'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/odoo15.conf

/etc/odoo15.conf

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

Do not forget to change the

my_admin_passwd

to something more secure.

Creating Systemd Unit File

A unit file is a configuration ini-style file that holds data about a service.

Open up your text editor and create a file named

odoo15.service

with the following content:

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

/etc/systemd/organisation/odoo15.service

[Unit] Description=Odoo15 Requires=postgresql.service After=network.target postgresql.service  [Service] Blazon=unproblematic SyslogIdentifier=odoo15 PermissionsStartOnly=truthful User=odoo15 Grouping=odoo15 ExecStart=/opt/odoo15/odoo-venv/bin/python3 /opt/odoo15/odoo/odoo-bin -c /etc/odoo15.conf StandardOutput=journal+panel  [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 offset on boot by running:

sudo systemctl enable --now odoo15

Verify that the service is upwardly and running:

sudo systemctl status odoo15

The output should look something like below, showing that the Odoo service is active and running:

● odoo15.service - Odoo15      Loaded: loaded (/etc/systemd/organisation/odoo15.service; enabled; vendor preset: enabled)      Agile: active (running) since Tue 2021-10-26 09:56:28 UTC; 28s agone ...        

You lot can check the messages logged by the Odoo service using the command below:

sudo journalctl -u odoo15

Testing the Installation

Open your browser and type:

http://<your_domain_or_IP_address>:8069

Bold the installation is successful, a screen like to the following will announced:

Install Odoo 15 on Ubuntu

Configuring Nginx as SSL Termination Proxy

The default Odoo web server is serving traffic over HTTP. To brand the Odoo deployment more than secure, we will set Nginx as an SSL termination proxy that volition serve the traffic over HTTPS.

SSL termination proxy is a proxy server that handles the SSL encryption/decryption. This means that the termination proxy (Nginx) will process and decrypt incoming TLS connections (HTTPS), and pass on the unencrypted requests to the internal service (Odoo). The traffic betwixt Nginx and Odoo will not be encrypted (HTTP).

Using a opposite proxy gives you a lot of benefits such as Load Balancing, SSL Termination, Caching, Compression, Serving Static Content, and more.

Ensure that you accept met the following prerequisites before standing with this section:

  • Domain name pointing to your public server IP. We'll use
    example.com
    .
  • Nginx installed .
  • SSL certificate for your domain. You can install a free Permit's Encrypt SSL certificate .

Open your text editor and create/edit the domain server block:

sudo nano /etc/nginx/sites-enabled/case.com.conf

The following configuration sets upwardly SSL Termination, HTTP to HTTPS redirection , Www to non-World wide web redirection, cache the static files, and enable GZip pinch./etc/nginx/sites-enabled/example.com.conf

# Odoo servers upstream odoo {  server 127.0.0.i:8069; }  upstream odoochat {  server 127.0.0.1:8072; }  # HTTP -> HTTPS server {     listen 80;     server_name www.example.com case.com;      include snippets/letsencrypt.conf;     render 301 https://example.com$request_uri; }  # Www -> Not WWW server {     heed 443 ssl http2;     server_name world wide web.instance.com;      ssl_certificate /etc/letsencrypt/live/instance.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 {     mind 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 10-Forwarded-Proto $scheme;     proxy_set_header X-Real-IP $remote_addr;      # SSL parameters     ssl_certificate /etc/letsencrypt/alive/example.com/fullchain.pem;     ssl_certificate_key /etc/letsencrypt/live/case.com/privkey.pem;     ssl_trusted_certificate /etc/letsencrypt/live/instance.com/concatenation.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;     }      # Enshroud 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/plainly text/xml awarding/xml application/json awarding/javascript;     gzip on; }        

Don't forget to replace example.com with your Odoo domain and prepare the correct path to the SSL document files. The snippets used in this configuration are created in this guide .

Once you're done, restart the Nginx service :

sudo systemctl restart nginx

Side by side, we need to tell Odoo to use the proxy. To exercise so, open the configuration file and add together the post-obit line:/etc/odoo15.conf

proxy_mode = True        

Restart the Odoo service for the changes to accept consequence:

sudo systemctl restart odoo15

At this point, the opposite proxy is configured, and you tin admission your Odoo case at

https://example.com

.

Changing the Binding Interface

This step is optional, merely it is a good security exercise.

Past default, the Odoo server listens to port

8069

on all interfaces. To disable direct access to the Odoo instance, you lot can either block port

8069

for all public interfaces or strength Odoo to heed only on the local interface.

We'll configure Odoo to mind only on

127.0.0.ane

. Open the configuration add the following two lines at the end of the file:/etc/odoo15.conf

xmlrpc_interface = 127.0.0.1 netrpc_interface = 127.0.0.one        

Relieve the configuration file and restart the Odoo server for the changes to take effect:

sudo systemctl restart odoo15

Enabling Multiprocessing

Past default, Odoo is working in multithreading mode. For product deployments, information technology is recommended to change to the multiprocessing server every bit it increases stability and makes better usage of the system resources.

To enable multiprocessing, you lot need to edit the Odoo configuration and set a non-zip number of worker processes. The number of workers is calculated based on the number of CPU cores in the system and the available RAM retentiveness.

According to the official Odoo documentation , to calculate the workers' number and required RAM retentivity size, you tin can use the following formulas and assumptions:

Worker number adding

  • Theoretical maximal number of worker = (system_cpus * 2) + 1
  • 1 worker tin can serve ~= half-dozen concurrent users
  • Cron workers also require CPU

RAM retentivity size adding

  • Nosotros will consider that 20% of all requests are heavy requests, and 80% are lighter ones. Heavy requests are using effectually ane GB of RAM while the lighter ones are using effectually 150 MB of RAM
  • Needed RAM =
    number_of_workers * ( (light_worker_ratio * light_worker_ram_estimation) + (heavy_worker_ratio * heavy_worker_ram_estimation) )

If y'all practice not know how many CPUs you have on your system, use the following

grep

control:

grep -c ^processor /proc/cpuinfo

Let'southward say you take a organisation with 4 CPU cores, 8 GB of RAM memory, and xxx concurrent Odoo users.

  • 30 users / 6 = **5**
    (5 is theoretical number of workers needed )
  • (iv * two) + 1 = **ix**
    ( 9 is the theoretical maximum number of workers)

Based on the adding in a higher place, y'all tin can utilize 5 workers + ane worker for the cron worker that is a full of six workers.

Calculate the RAM memory consumption based on the number of workers:

  • RAM = half dozen * ((0.8*150) + (0.2*1024)) ~= 2 GB of RAM

The adding shows that the Odoo installation will demand effectually 2GB of RAM.

To switch to multiprocessing mode, open the configuration file and suspend the calculated values:/etc/odoo15.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 odoo15

The residual of the arrangement resources will be used by other services that run on this system. In this guide, we installed Odoo along with PostgreSQL and Nginx on the aforementioned server. Depending on your prepare y'all may also have other services running on your server.

Determination

This article explained how to install and configure Odoo 15 on Ubuntu twenty.04 in a Python virtual environment using Nginx as a reverse proxy. Nosotros've as well shown yous how to enable multiprocessing and optimize Odoo for a production surroundings.

You may also want to check our tutorial well-nigh how to create automatic daily backups of Odoo databases .

If you have questions, feel free to leave a comment beneath.

source: https://linuxize.com/mail/how-to-install-odoo-15-on-ubuntu-xx-04/

mylesroich1976.blogspot.com

Source: https://www.logicweb.com/knowledgebase/linux/how-to-install-odoo-15-on-ubuntu-20-04/

0 Response to "Odoo (Using Sudo)"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel