12

Install Odoo 14 on CentOS 8 With Let's Encrypt SSL | ComputingForGeeks

 2 years ago
source link: https://computingforgeeks.com/install-odoo-on-centos-with-lets-encrypt/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Install Odoo 14 on CentOS 8 With Let's Encrypt SSL
Search

This post has been written to guide Linux users through the installation of Odoo 14 ERP system on CentOS 8. Odoo is an open source business management application with features of POS, CRM, Project Management, Website builder, Marketing, Warehouse Management, eCommerce, Billing & Accounting, Manufacturing and many other cool features. These extra features can be unlocked through plenty of Odoo Plugins available for installation.

As of this article update the latest release of Odoo ERP software is version 14. We will kickoff the installation with the upgrade of the system, installing all required dependencies such PostgreSQL database server and finally doing the actual installation of Odoo ERP 14 on CentOS 8. Nginx will be used as frontend proxy to the Odoo 14 ERP & CRM System on CentOS 8.

Step 1: Update OS, Setup Hostname and DNS

Login to CentOS 8 Server and perform system update, then reboot.

sudo dnf -y update
sudo reboot

After the system is rebooted, configure 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 validate it is working by doing ping or dig.

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

Step 2: Add EPEL Repository to CentOS server

Add EPEL repository to CentOS 8 by running the command.

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

Put SELinux in permissive 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. The packages are available in DNF Modules.

Disable current default PostgreSQL module.

sudo dnf -qy module disable postgresql

Enable PostgreSQL 13 module.

sudo dnf module -y enable postgresql:13

Then install PostgreSQL server and client packages.

sudo dnf -y install @postgresql

After installation, database initialization is required before service can be started.

$ 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 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 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 to install is 0.12.5 and is available on the wkhtmltopdf download page, in the archive section.

sudo yum -y install wget
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.centos8.x86_64.rpm
sudo yum localinstall ./wkhtmltox-0.12.6-1.centos8.x86_64.rpm

Continue with the installation:

Dependencies resolved.
======================================================================================================================================================================================================
 Package                                              Architecture                           Version                                               Repository                                    Size
======================================================================================================================================================================================================
Installing:
 wkhtmltox                                            x86_64                                 1:0.12.6-1.centos8                                    @commandline                                  15 M
Installing dependencies:
 libfontenc                                           x86_64                                 1.1.3-8.el8                                           appstream                                     37 k
 libjpeg-turbo                                        x86_64                                 1.5.3-10.el8                                          appstream                                    156 k
 libpkgconf                                           x86_64                                 1.4.2-1.el8                                           baseos                                        35 k
 pkgconf                                              x86_64                                 1.4.2-1.el8                                           baseos                                        38 k
 pkgconf-m4                                           noarch                                 1.4.2-1.el8                                           baseos                                        17 k
 pkgconf-pkg-config                                   x86_64                                 1.4.2-1.el8                                           baseos                                        15 k
 ttmkfdir                                             x86_64                                 3.0.9-54.el8                                          appstream                                     62 k
 xorg-x11-font-utils                                  x86_64                                 1:7.5-40.el8                                          appstream                                    103 k
 xorg-x11-fonts-75dpi                                 noarch                                 7.5-19.el8                                            appstream                                    2.8 M
 xorg-x11-fonts-Type1                                 noarch                                 7.5-19.el8                                            appstream                                    522 k

Transaction Summary
======================================================================================================================================================================================================
Install  11 Packages

Total size: 19 M
Total download size: 3.7 M
Installed size: 129 M
Is this ok [y/N]: y

Confirm installed version.

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

You’re good to proceed to the next step of actual installation of Odoo 14 on CentOS 8.

Step 5: Install Odoo 14 on CentOS 8

Add EPEL repositpory:

sudo yum -y install epel-release

Also enable 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 user and group.

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

Set password for the user account created.

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

Check user details:

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

Switch to the account of the user created:

sudo su - odoo

Clone release 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 virtual environment created.

source odoo-venv/bin/activate

Install Python dependencies in requirements file.

pip3 install -r odoo/requirements.txt

After successful installations deactivate the virtual environment,

deactivate
exit

Create Odoo log file:

sudo touch /var/log/odoo.log

Create Custom Addons Path:

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

Set correct directory permissions:

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

Create Odoo instance configuration file:

$ sudo vim  /etc/odoo.conf
[options]
proxy_mode = True
; This is the password that allows database operations:
admin_passwd = MyStr0ngAdminP@ssw0rd
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

Create Systemd 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 odoo service created.

sudo systemctl start odoo
sudo systemctl restart odoo

Enable it to start at boot.

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

Confirm if Odoo service is set to start at boot.

$ systemctl is-enabled odoo
enabled

Check if 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.

The Odoo service should bind to TCP port 8069 once started.

$ 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 <->

Step 6: Configure Nginx Proxy (Without SSL) – Not recommended

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 snippet to fit 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 with your domain name, then validate 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 all looks good, restart Nginx.

sudo systemctl restart nginx

Step 7: Configure Nginx Proxy (With SSL Certificate) – Recommended

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

Install Nginx on CentOS 8 Server.

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

Install certbot tool.

sudo yum -y install epel-release wget
sudo yum -y install certbot

Stop Nginx service.

sudo systemctl stop nginx

Get Let’s Encrypt SSL certificates for your domain.

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

The path to certificate files is shown in the “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/bin/certbot renew --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx"

Create Nginx configuration file.

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

Paste below into the file and modify it to suit 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;
}

Validate your Nginx configurations.

$ 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 Odoo Web page on your domain name from a web – https://DNShostname.

You can also access the Odoo Web page directly on:

http://<your_server_IP_address>:8069

On the first page, set database name, admin user email address and password for the admin user.

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

More articles on CentOS 8:


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK