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 formatClose

This article is written to guide Linux users to install Odoo 14 ERP system on CentOS 8. Odoo is an open source business management application with POS, CRM, project management, website builder, marketing, warehouse management, e-commerce, billing and other functions. With accounting, manufacturing and many other cool functions.These extra features can be unlocked by a large number Odoo plugin Can be used for installation.

At the time this article was updated, the latest version of Odoo ERP software was version 14. We will start the installation through the system upgrade, install all the necessary dependencies (such as the PostgreSQL database server), and finally perform the actual installation of Odoo ERP 14 on CentOS 8. Nginx will be used as a front-end agent for Odoo 14 ERP and CRM systems on CentOS 8.

Step 1: Update the operating system, set the host name and DNS

Log in to the CentOS 8 server and perform a system update, then reboot.

sudo dnf -y update
sudo reboot

After rebooting the system, configure the correct hostname.

sudo hostnamectl set-hostname erp.hirebestengineers.com --static
sudo hostnamectl set-hostname erp.hirebestengineers.com --transient

Also add a valid A record in your DNS server.

Save the record and verify it is working properly via ping or dig.

$ sudo dnf -y install bind-utils
$ dig A erp.hirebestengineers.com +short
168.119.127.45

Step 2: Add the EPEL repository to the CentOS server

Add the EPEL repository to CentOS 8 by running the command.

sudo yum -y install epel-release vim bash-completion

Put SELinux in relaxed mode.

sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

Run the yum repolist command.

$ sudo yum repolist
repo id                                                     repo name
AppStream                                                   CentOS-8 - AppStream
BaseOS                                                      CentOS-8 - Base
epel                                                        Extra Packages for Enterprise Linux 8 - x86_64
epel-modular                                                Extra Packages for Enterprise Linux Modular 8 - x86_64
extras                                                      CentOS-8 - Extras

Step 3: Install PostgreSQL database server

Odoo ERP repository uses PostgreSQL database server for data storage. These packages are available in the DNF module.

Disable the current default PostgreSQL module.

sudo dnf -qy module disable postgresql

Enable the PostgreSQL 12 module.

sudo dnf module -y enable postgresql:12

Then install the PostgreSQL server and client software packages.

sudo dnf -y install @postgresql

After installation, you need to initialize the database before starting the service.

$ sudo /usr/bin/postgresql-setup --initdb --unit postgresql
 * Initializing database in '/var/lib/pgsql/data'
 * Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log

Start and enable the database server.

$ sudo systemctl enable --now postgresql
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /usr/lib/systemd/system/postgresql.service.

Create an odoo database user.

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

Step 4: Install wkhtmltopdf on CentOS 8

Odoo uses wkhtmltopdf to generate reports in PDF format.The recommended version of wkhtmltopdf is 0.12.5, which can be obtained from the following website wkhtmltopdf download page, In the archive section.

sudo dnf install -y https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox-0.12.5-1.centos8.x86_64.rpm

Confirm the installed version.

$ wkhtmltopdf --version
wkhtmltopdf 0.12.5 (with patched qt)

You can proceed to the next step to actually install Odoo 14 on CentOS 8.

Step 5: Install Odoo 14 on CentOS 8

Add EPEL repository:

yum -y install epel-release

Also enable the PowerTools repository.

sudo dnf config-manager --set-enabled PowerTools

Install Python and other build dependencies:

sudo yum -y install vim bash-completion zip git gcc openldap-devel python3 python3-devel redhat-rpm-config libxslt-devel libjpeg-devel freetype-devel bzip2-devel

Add Odoo system users and groups.

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

Set a password for the created user account.

$ sudo passwd odoo
Changing password for user odoo.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

View user details:

$ id odoo
uid=992(odoo) gid=989(odoo) groups=989(odoo)

Switch to the created user account:

$ sudo su - odoo

Copy the version 14 branch from Github.

git -C /opt/odoo/ clone https://www.github.com/odoo/odoo --depth 1 --branch 14.0

Create Python Virtualenv.

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

Activate the created virtual environment.

source odoo-venv/bin/activate

Install Python dependencies in the requirements file.

pip3 install -r odoo/requirements.txt

After successful installation, disable the virtual environment,

deactivate
exit

Create Odoo log file:

sudo touch /var/log/odoo.log

Create a custom plugin path:

sudo mkdir /opt/odoo/odoo/custom-addons

Set the correct directory permissions:

sudo chown -R odoo:odoo /opt/odoo/ /var/log/odoo.log

Create Odoo instance configuration file:

sudo tee  /etc/odoo.conf<<EOF
[options]
proxy_mode = True
; This is the password that allows database operations:
admin_passwd = [email protected]
db_host = False
db_port = False
db_user = odoo
db_password = False
xmlrpc_port = 8069
logfile = /var/log/odoo.log
logrotate = True
addons_path = /opt/odoo/odoo/addons,/opt/odoo/odoo/custom-addons
EOF

Create a system service unit file.

sudo tee /etc/systemd/system/odoo.service<<EOF
[Unit]
Description=Odoo ERP Server
Requires=postgresql.service
After=network.target postgresql.service

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

[Install]
WantedBy=multi-user.target
EOF

Reload system services:

sudo systemctl daemon-reload

Start the created odoo service.

sudo systemctl start odoo
sudo systemctl restart odoo

Make it start at boot time.

$ sudo systemctl enable odoo
Created symlink /etc/systemd/system/multi-user.target.wants/odoo.service → /etc/systemd/system/odoo.service.

Confirm whether the Odoo service is set to start at startup.

$ systemctl is-enabled odoo
enabled

Check if it is running.

$ systemctl status odoo
● odoo.service - Odoo ERP Server
   Loaded: loaded (/etc/systemd/system/odoo.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2020-10-11 18:38:30 CEST; 48s ago
 Main PID: 25201 (python3)
    Tasks: 4 (limit: 24392)
   Memory: 59.2M
   CGroup: /system.slice/odoo.service
           └─25201 /opt/odoo/odoo-venv/bin/python3 /opt/odoo/odoo/odoo-bin -c /etc/odoo.conf

Oct 11 18:38:30 erp.hirebestengineers.com systemd[1]: Started Odoo ERP Server.

Odoo service should be bound to TCP port 8069 Once it starts.

$ sudo ss -tunelp | grep 8069
tcp     LISTEN   0        128              0.0.0.0:8069          0.0.0.0:*       users:(("python3",pid=25201,fd=4)) uid:992 ino:64882 sk:5 <->

Install Nginx web server on CentOS 8:

sudo yum -y install nginx
sudo systemctl enable --now nginx

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.hirebestengineers.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;
}

replace erp.computingforgeeks Use your domain name, and then verify the Nginx configuration file.

$ 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 everything is normal, restart Nginx.

sudo systemctl restart nginx

If your server has a public IP, you can create a DNS A record for your domain to point to Odoo Server and request a free Let’s Encrypt SSL certificate.

Install Nginx on CentOS 8 server.

sudo yum -y install nginx
sudo systemctl enable --now nginx

Install the certbot-auto tool.

sudo yum -y install wget
wget https://dl.eff.org/certbot-auto
chmod +x certbot-auto
sudo mv certbot-auto /usr/local/bin/certbot-auto

Stop the Nginx service.

sudo systemctl stop nginx

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

export DOMAIN="erp.hirebestengineers.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

The path of the certificate file is displayed in “Important notes” section.

IMPORTANT NOTES:
Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/erp.hirebestengineers.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/erp.hirebestengineers.com/privkey.pem
Your cert will expire on 2021-01-09. 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 for certificate renewal.

$ 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

Paste the following into the file, modify It suits your environment.

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

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

server {
    listen 443 ssl;
    server_name erp.hirebestengineers.com;
    access_log /var/log/nginx/odoo_access.log;
    error_log /var/log/nginx/odoo_error.log;
   
   # SSL
    ssl_certificate /etc/letsencrypt/live/erp.hirebestengineers.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/erp.hirebestengineers.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/erp.hirebestengineers.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;
}

Verify your Nginx configuration.

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

Restart Nginx.

sudo systemctl restart nginx

Step 8: Access Odoo 14 on CentOS 8 server

Access the Odoo webpage from the domain name on the web-https:// DNShostname.

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

You can also visit the Odoo webpage directly at:

http://<your_server_IP_address>:8069

On the first page, set the database name, the email address of the administrator user, and the password of the administrator user.

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

You have now installed and run Odoo ERP on CentOS 8 server. Keep checking our website for the latest articles.

More articles about CentOS 8:

How to install MicroK8s Kubernetes cluster on CentOS 8

How to configure TigerVNC on CentOS 8 in Rent

Install Google Hangouts client on CentOS 8

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

Sidebar