Let’s encrypt SSL to install Odoo 14 on Ubuntu 20.04

You can download this article in PDF format via the link below to support us.
Download the guide in PDF formatturn off

Odoo is an open source suite of web-based business applications that can be managed through a single console. There are a series of business applications on Odoo, including open source CRM, website builder, e-commerce, warehouse management, project management, billing and accounting, point of sale, human resources, marketing, manufacturing, procurement management, etc. In this article, we will delve into the installation and configuration of Odoo 14 using Let’s Encrypt SSL Certificates on Ubuntu 20.04 Linux.

Odoo business applications can be installed and used as standalone applications, but they can also be seamlessly integrated, so you can get fully functional features. Open source ERP When you install multiple applications. This guide will also explain how to configure the Nginx proxy with a “Let’s Encrypt SSL” certificate, but you can use a custom or any other custom SSL certificate signed by a known CA.

Step 1: Update the Ubuntu system

We always start the installation with system updates and upgrades of all installed packages.

sudo apt update
sudo apt upgrade -y

Wait for all packages to be updated, and then reboot the system. This is necessary when there is a kernel update.

sudo systemctl reboot

Step 2: Install the PostgreSQL database server

Odoo needs a database server to store data. We will install the default version of the PostgreSQL server on the Ubuntu upstream repository.

Install the default version available in the Ubuntu repository. run:

sudo apt install postgresql postgresql-client -y

After installation, the database service will start.

$ systemctl status postgresql*
● [email protected] - PostgreSQL Cluster 12-main
     Loaded: loaded (/lib/systemd/system/[email protected]; enabled-runtime; vendor preset: enabled)
     Active: active (running) since Fri 2020-11-06 10:34:45 CET; 1min 6s ago
   Main PID: 2177 (postgres)
      Tasks: 7 (limit: 2286)
     Memory: 18.0M
     CGroup: /system.slice/system-postgresql.slice/[email protected]
             ├─2177 /usr/lib/postgresql/12/bin/postgres -D /var/lib/postgresql/12/main -c config_file=/etc/postgresql/12/main/postgresql.conf
             ├─2179 postgres: 12/main: checkpointer
             ├─2180 postgres: 12/main: background writer
             ├─2181 postgres: 12/main: walwriter
             ├─2182 postgres: 12/main: autovacuum launcher
             ├─2183 postgres: 12/main: stats collector
             └─2184 postgres: 12/main: logical replication launcher

Nov 06 10:34:43 ubuntu systemd[1]: Starting PostgreSQL Cluster 12-main...
Nov 06 10:34:45 ubuntu systemd[1]: Started PostgreSQL Cluster 12-main.

● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2020-11-06 10:34:40 CET; 1min 11s ago
   Main PID: 1911 (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 2286)
     Memory: 0B
     CGroup: /system.slice/postgresql.service

Nov 06 10:34:40 ubuntu systemd[1]: Starting PostgreSQL RDBMS...
Nov 06 10:34:40 ubuntu systemd[1]: Finished PostgreSQL RDBMS.

Step 3: Install wkhtmltopdf

wkhtmltopdf is necessary for printing reports because it converts html to pdf.version wkhtmltopdf The version available in the Ubuntu repository does not support headers and footers, so it is not used as a direct dependency.

Install wkhtmltopdf and wkhtmltoimage on Ubuntu/Linux

Step 4: Install Odoo 14 on Ubuntu 20.04 / 18.04 LTS

Add the Odoo deb repository so that Odoo 14 can be installed on Ubuntu 20.04 | 18.04.

wget -O - https://nightly.odoo.com/odoo.key | sudo apt-key add -
echo "deb http://nightly.odoo.com/14.0/nightly/deb/ ./" | sudo tee /etc/apt/sources.list.d/odoo.list

Update the Apt cache and install Odoo 14 on Ubuntu 20.04 | 18.04.

sudo apt update
sudo apt install odoo

Agree to start the installation:

The following NEW packages will be installed:
  docutils-common fonts-font-awesome fonts-inconsolata fonts-roboto-unhinted graphviz libann0 libcairo2 libcdt5 libcgraph6 libdatrie1 libgd3 libgraphite2-3
  libgts-0.7-5 libgvc6 libgvpr2 libharfbuzz0b libice6 libimagequant0 libjbig0 libjpeg8 libjs-jquery libjs-underscore liblab-gamut1 liblcms2-2 libpango-1.0-0
  libpangocairo-1.0-0 libpangoft2-1.0-0 libpathplan4 libpixman-1-0 libsass1 libsm6 libthai-data libthai0 libtiff5 libwebp6 libwebpdemux2 libwebpmux3 libxaw7
  libxcb-render0 libxcb-shm0 libxmu6 libxpm4 libxt6 odoo python-babel-localedata python3-aiohttp python3-appdirs python3-async-timeout python3-babel python3-bs4
  python3-cached-property python3-dateutil python3-decorator python3-defusedxml python3-docutils python3-feedparser python3-freezegun python3-gevent
  python3-greenlet python3-html2text python3-isodate python3-libsass python3-lxml python3-mako python3-mock python3-multidict python3-ofxparse python3-passlib
  python3-pbr python3-pil python3-polib python3-psutil python3-psycopg2 python3-pydot python3-pyparsing python3-pypdf2 python3-qrcode python3-reportlab
  python3-reportlab-accel python3-requests-toolbelt python3-roman python3-soupsieve python3-stdnum python3-suds python3-tz python3-usb python3-vobject
  python3-werkzeug python3-xlrd python3-xlsxwriter python3-xlwt python3-yarl python3-zeep sgml-base xml-core
0 upgraded, 95 newly installed, 0 to remove and 0 not upgraded.
Need to get 87.3 MB of archives.
After this operation, 665 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

After installing Odoo on Ubuntu 20.04 | 18.04 Linux, the service will start automatically.

$ systemctl status odoo
● odoo.service - Odoo Open Source ERP and CRM
     Loaded: loaded (/lib/systemd/system/odoo.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2020-11-06 10:50:50 CET; 11min ago
   Main PID: 9090 (odoo)
      Tasks: 4 (limit: 2286)
     Memory: 68.9M
     CGroup: /system.slice/odoo.service
             └─9090 /usr/bin/python3 /usr/bin/odoo --config /etc/odoo/odoo.conf --logfile /var/log/odoo/odoo-server.log

Nov 06 10:50:50 ubuntu systemd[1]: Started Odoo Open Source ERP and CRM.

Set the service to start every time the system reboots.

$ sudo systemctl enable --now odoo
enabled

The service is started on port 8069. You can use the following command to confirm the service.

$ ss -tunelp | grep 8069
tcp   LISTEN  0       128                  0.0.0.0:8069           0.0.0.0:*      uid:113 ino:1906251 sk:d <-> 

Step 5: Configure Nginx proxy for Odoo 13

Install Nginx web server on Ubuntu system:

sudo apt -y install vim nginx

There are two options for Nginx proxy configuration-when using HTTPS and when not providing traffic through a secure connection. In this section, we will consider two settings.

Set up Nginx HTTP proxy for Odoo

Create a new configuration file for odoo.

sudo vim /etc/nginx/conf.d/odoo.conf

Modify this configuration code snippet to suit your setup.

# Odoo Upstreams
upstream odooserver {
 server 127.0.0.1:8069;
}

server {
    listen 80;
    server_name erp.computingforgeeks.com;
    access_log /var/log/nginx/odoo_access.log;
    error_log /var/log/nginx/odoo_error.log;


    # Proxy settings
    proxy_read_timeout 720s;
    proxy_connect_timeout 720s;
    proxy_send_timeout 720s;
    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;

    # Request for root domain
    location / {
       proxy_redirect off;
       proxy_pass http://odooserver;
    }

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

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

In this example, my service domain is erp.computingforgeeks.com, Replace it with the correct domain to use with Odoo. External access also requires valid DNS records.

Check your configuration syntax:

$ sudo nginx  -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

If you think the settings are correct, restart the nginx service.

sudo systemctl restart nginx

No errors will be encountered when restarting.

$ systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-10-19 17:34:39 UTC; 5s ago
     Docs: man:nginx(8)
  Process: 626 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 615 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 631 (nginx)
    Tasks: 2 (limit: 2362)
   CGroup: /system.slice/nginx.service
           ├─631 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           └─632 nginx: worker process
....

Use Let’s Encrypt SSL Certificate for Odoo on Nginx

It is always recommended to use SSL encryption for production deployments. Let’s Encrypt is a free SSL product, you can use it in the installer.

Obtain a Let’s Encrypt SSL certificate for your domain.

wget https://dl.eff.org/certbot-auto
chmod +x certbot-auto
sudo mv certbot-auto /usr/local/bin/certbot-auto
sudo systemctl stop nginx

export DOMAIN="erp.computingforgeeks.com"
export EMAIL="[email protected]"
sudo /usr/local/bin/certbot-auto certonly --standalone -d ${DOMAIN} --preferred-challenges http --agree-tos -n -m ${EMAIL} --keep-until-expiring

If the execution passes, the path of the certificate and chain file will be printed out.

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/erp.computingforgeeks.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/erp.computingforgeeks.com/privkey.pem
   Your cert will expire on 2020-01-17. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again. To non-interactively renew *all* of your certificates, run
   "certbot-auto renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Create cron to renew the certificate.

$ sudo crontab -e
15 3 * * * /usr/local/bin/certbot-auto renew --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx"

Create Nginx configuration file.

sudo vim /etc/nginx/conf.d/odoo.conf

Modify and add to the file below.

# Odoo Upstreams
upstream odooserver {
 server 127.0.0.1:8069;
}

# http to https redirection
server {
    listen 80;
    server_name erp.computingforgeeks.com;
    return 301 https://erp.computingforgeeks.com$request_uri;
}

server {
    listen 443 ssl;
    server_name erp.computingforgeeks.com;
    access_log /var/log/nginx/odoo_access.log;
    error_log /var/log/nginx/odoo_error.log;
   
   # SSL
    ssl_certificate /etc/letsencrypt/live/erp.computingforgeeks.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/erp.computingforgeeks.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/erp.computingforgeeks.com/chain.pem;


    # Proxy settings
    proxy_read_timeout 720s;
    proxy_connect_timeout 720s;
    proxy_send_timeout 720s;
    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;

    # Request for root domain
    location / {
       proxy_redirect off;
       proxy_pass http://odooserver;
    }

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

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

Don’t forget to substitute erp.computingforgeeks.com With your domain name.

Restart Nginx.

sudo systemctl restart nginx

Step 6: Access the Odoo web interface

Visit the Odoo webpage on your domain name from a web browser.

Enter the required details to create the database. After clicking “Create Database”, you will be redirected to the “Management” page, where you can install Odoo business applications.Let's encrypt SSL to install Odoo 14 on Ubuntu 20.04

If https is indeed configured, the page should be loaded through a secure tunnel.Let's encrypt SSL to install Odoo 14 on Ubuntu 20.04

access Odoo documentation page understand more.

Similar guides:

Let’s encrypt SSL to install Odoo 14 on CentOS 8

You can download this article in PDF format via the link below to support us.
Download the guide in PDF formatturn off

Sidebar