Monday, May 7, 2018

How to deploy Odoo 11 on Ubuntu 18.04

https://linuxize.com/post/how-to-deploy-odoo-11-on-ubuntu-18-04

Odoo
is the most popular all-in-one business software in the world packed up
a range of business applications, including CRM, website ,e-Commerce,
billing, accounting, manufacturing, warehouse, project management,
inventory and much more, all seamlessly integrated.
There are
several ways to install Odoo depending on the required use case. This
guide covers the steps necessary for installing and configuring Odoo for
production using Git source and Python virtualenv on a Ubuntu 18.04
system.

We
will install odoo from the GitHub repository so we can have more
control over versions and updates. We will also use virtualenv which is a
tool to create isolated Python environments.
Before starting with the installation process, make sure you switch to odoo user.

sudo su - odoo

Copy

To confirm that you are logged-in as odoo user you can use the following command:

whoami

Copy

Now we can start with the installation process, first clone the odoo from the GitHub repository:

You have a SSL certificate installed for your domain. You can install a free Let’s Encrypt SSL certificate by following this introductions .

The
default Odoo web server is serving traffic over HTTP. To make our Odoo
deployment most secure we will configure Nginx as a SSL termination
proxy which will serve the traffic over HTTPS.
SSL termination
proxy is a proxy server which handles the SSL encryption/decryption.
This means that our termination proxy (Nginx) will handle and decrypt
incoming TLS connections (HTTPS), and it will pass on the unencrypted
requests to our internal service (Odoo) so the traffic between Nginx and
Odoo will not be encrypted (HTTP).
We need to tell Odoo that we will use a proxy, open the configuration file and add the following line:

/etc/odoo11.conf

proxy_mode = True

Copy

Restart the Odoo service for the changes to take effect:

sudo systemctl restart odoo11

Copy

Using
Nginx as a proxy give us several benefits. In this example we will
configure SSL Termination, HTTP to HTTPS redirection, WWW to non-WWW
redirection, cache the static files and enable GZip compression.

This
step is optional, but it is a good security practice. By default, Odoo
server listens to port 8069 on all interfaces, so if you want to disable
direct access to your Odoo instance you can either block the port 8069
for all public interfaces or force Odoo to listen only on the local
interface.
In this guide we will force Odoo to listen only on 127.0.0.1, open the Odoo configuration add the following two lines at the end of the file:

/etc/odoo11.conf

xmlrpc_interface = 127.0.0.1
netrpc_interface = 127.0.0.1

Copy

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

By
default, Odoo is working in multithreading mode. For production
deployments, it is recommended to switch to the multiprocessing server
as it increases stability, and make better usage of the system
resources. In order to enable multiprocessing we need to edit the Odoo
configuration and set a non-zero number of worker processes.

Multiprocessing mode is only available on Unix-based systems it is available on Windows systems

The number of workers is calculated based on the number of CPU cores in the system and the available RAM memory.
According to the official [Odoo documentation](“https://www.odoo.com/documentation/11.0/setup/deploy.html") to calculate the workers number and required RAM memory size we will use the following formulas and assumptions:Worker number calculation

theoretical maximal number of worker = (system_cpus * 2) + 1

1 worker can serve ~= 6 concurrent users

Cron workers also requires CPU

RAM memory size calculation

We
will consider that 20% of all requests are heavy requests, while 80%
are lighter ones. Heavy requests are using around 1 GB of RAM while the
lighter ones are using around 150 MB of RAM

The
rest of the system resources will be used by other services that run on
our machine. In this guide we installed Odoo along with PostgreSQL and
Nginx on a same server and depending on your setup you may also have
other services running on your server.