How to Install Odoo 14 on Fedora 33

Odoo (formerly known as OpenERP) is a self-hosted suite of over 10,000 open source applications suited for various business needs, including CRM, eCommerce, accounting, inventory, project management, and point of sale. These applications are fully integrated and accessed through a common web interface.

In this tutorial, we will learn to install Odoo 14 Stack on a Fedora 34 based server.

Prerequisites

  1. A Fedora 34 based server with a minimum of 2GB RAM to host Odoo Stack.
  2. A second Fedora 34 based server with a minimum of 2GB RAM for hosting the PostgreSQL database. You can, however, install the database on the same server as Odoo, but for production environments, it is highly recommended that you install it on a separate server. You can also choose any of the managed database options available from any provider of your choice.
  3. RAM requirement will depend on the number of concurrent users that will be using the stack. You can find a detailed guide on how to calculate system requirements in Odoo’s documentation.
  4. Keep your systems updated.
    $ sudo dnf update
    
  5. Essential packages.
    $ sudo dnf install wget curl bzip2 nano unzip policycoreutils-python-utils -y
    
  6. A non-root user with sudo privileges on both servers.

Configure Firewall rules

For this tutorial, we will assume you have firewalld firewall installed on both the servers.

On the Odoo server, we will need ports 22, 80, 443, 6010, 5432, and 8069 to be open. 22 is used for SSH, 80 is for HTTP, 443 is for HTTPS, 6010 is used for Odoo communication, PostgreSQL uses 5432, and 8069 is used by Odoo server application.

Check if the firewall is running.

$ sudo firewall-cmd --state
running

Check the current allowed services/ports.

$ sudo firewall-cmd --permanent --list-services

It should show the following output.

dhcpv6-client mdns ssh

Run the following commands to open the required ports on the Odoo server.

$ sudo firewall-cmd --permanent --add-service=http
$ sudo firewall-cmd --permanent --add-service=https
$ sudo firewall-cmd --permanent --add-port=6010/tcp
$ sudo firewall-cmd --permanent --add-port=5432/tcp
$ sudo firewall-cmd --permanent --add-port=8069/tcp
$ sudo firewall-cmd --permanent --add-port=8072/tcp

Reload the Firewall.

$ sudo systemctl reload firewalld

On the PostgreSQL server, we need to open ports 22, 6010, and 5432. Open them using the commands we just discussed.

Assign Hostnames

You can either use the IP addresses of the servers or use their Fully Qualified Domain Names (FQDN), if available. For our tutorial, we will be using FQDNs, and for that, we need to set hostnames on both servers.

On the Odoo server, open the /etc/hosts file.

$ sudo nano /etc/hosts

Make sure it looks like the following.

127.0.0.1 	localhost
127.0.0.1	odoo.yourdomain.com		odoo
10.1.1.10	postgresql.yourdomain.com	postgresql

On the PostgreSQL server, open the file and make sure it looks like the following.

127.0.0.1 	localhost
127.0.0.1	postgresql.yourdomain.com	postgresql
10.1.2.10	odoo.yourdomain.com		odoo

Press Ctrl + X to close the editor and press Y when prompted to save the file.

Install and Configure PostgreSQL

Fedora 34 ships with PostgreSQL 13 by default, and we will install that. Run the following command on the PostgreSQL server.

$ sudo dnf install postgresql-server postgresql-server-devel

Next, run the PostgreSQL setup program to create the configuration files for it.

$ sudo postgresql-setup initdb

Enable and Start the PostgreSQL service.

$ sudo systemctl enable postgresql
$ sudo systemctl start postgresql

Next, we need to create a database user odoo.

$ sudo -u postgres createuser odoo -U postgres -dP

The option -u executes the command as postgres user.

The option -U indicates the user name to connect as.

The option -d grants the user permission to create databases.

The option -p prompts for the new user’s password.

Configure Host-Based Authentication

We need to permit the PostgreSQL service to be able to connect to the Odoo server.

First, stop the PostgreSQL service.

$ sudo systemctl stop postgresql

Open the file /var/lib/pgsql/data/pg_hba.conf for editing.

$ sudo nano /var/lib/pgsql/data/pg_hba.conf

Paste the following line at the end.

host		all		odoo		odoo.yourdomain.com		md5

This line grants permission to the odoo user to connect to all the databases within this server. You can specify the name of the databases, too, instead of using the all keyword.

Press Ctrl + X to close the editor and press Y when prompted to save the file.

Configure PostgreSQL Listening address

Next, we need to allow the database server to listen to remote connections. Open the file /var/lib/pgsql/data/postgresql.conf for editing.

$ sudo nano /var/lib/pgsql/data/postgresql.conf

Change the line listen_addresses from

#listen_addresses = 'localhost' # what IP address(es) to listen on;

to.

#From CONNECTIONS AND AUTHENTICATION Section
listen_addresses = '*'

The * means it will listen to all the IP addresses. You can change it to the IP address of your odoo instance.

Press Ctrl + X to close the editor and press Y when prompted to save the file.

Enable and Start PostgreSQL service

Since our configuration is finished, it is time to start the PostgreSQL service.

$ sudo systemctl start postgresql

Install Odoo

Even though Odoo ships with official repositories for Fedora, they are not compatible with Fedora 34 and can give multiple problems. Therefore, we will choose the manual installation.

Install dependencies and Prepare for installation

Create a new system user for managing the Odoo processes on the Odoo server. You can choose whatever username you want, but it should be the same as the PostgreSQL username chosen before.

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

Install important libraries for Odoo 14, including Git, Python3, and pip.

 $ sudo dnf install python3 python3-devel git gcc sassc redhat-rpm-config libxslt-devel bzip2-devel openldap-devel libjpeg-devel freetype-devel libpq-devel gcc-c++

Install Wkhtmltopdf

Wkhtmltopdf is a set of command-line tools to render HTML pages into PDF format. It is required by Odoo to print PDF reports. You can install it directly from Fedora’s repository.

$ sudo dnf install wkhtmltopdf

Download Odoo Files

Switch to the odoo user.

$ sudo su - odoo

Clone Odoo’s Github repository onto your system.

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

For our purpose, we are copying Odoo to the /opt/odoo/odoo directory from where you will install it.

Set up Virtualenv Python Environment

This step is optional but is recommended since a virtual python environment for Odoo will help avoid conflicts with the Operating system’s Python modules, especially when performing OS upgrades.

For this, we will use virtualenv.

  1. Create a new virtualenv environment for Odoo.
    $ python3 -m venv /opt/odoo/odoo-env
    
  2. Activate the virtual environment. We are creating an environment under the system user’s home directory. You are free to choose any location you like.
    $ source /opt/odoo/odoo-env/bin/activate
    
  3. Update PIP just in case.
    (odoo-env) $ pip3 install --upgrade pip
    
  4. Install Python’s wheel in the virtual environment.
    (odoo-env) $ pip3 install wheel
    

Install Python Dependencies

Install the Python dependencies required by Odoo 14.

(odoo-env) $ pip3 install -r /opt/odoo/odoo/requirements.txt

The requirements will take some time to install, so be patient.

Check whether the requirements are installed correctly by checking the list of installed Python modules.

$ pip3 list
Package                       Version
----------------------------- ---------
appdirs           1.4.4
attrs             21.2.0
Babel             2.6.0
beautifulsoup4    4.9.3
cached-property   1.5.2
certifi           2021.5.30
chardet           3.0.4
decorator         4.3.0
defusedxml        0.7.1
docutils          0.14
ebaysdk           2.1.5
feedparser        5.2.1
freezegun         0.3.15
gevent            20.9.0
greenlet          0.4.17
html2text         2018.1.9
idna              2.6
isodate           0.6.0
Jinja2            2.11.2
libsass           0.17.0
lxml              4.6.1
Mako              1.0.7
MarkupSafe        1.1.0
num2words         0.5.6
ofxparse          0.19
passlib           1.7.1
Pillow            8.1.1
pip               21.2.2
polib             1.1.0
psutil            5.6.6
psycopg2          2.8.5
pyasn1            0.4.8
pyasn1-modules    0.2.8
pydot             1.4.1
pyparsing         2.4.7
PyPDF2            1.26.0
pyserial          3.4
python-dateutil   2.7.3
python-ldap       3.1.0
python-stdnum     1.8
pytz              2019.1
pyusb             1.0.2
qrcode            6.1
reportlab         3.5.55
requests          2.21.0
requests-toolbelt 0.9.1
setuptools        53.0.0
six               1.16.0
soupsieve         2.2.1
urllib3           1.24.3
vobject           0.9.6.1
Werkzeug          0.16.1
wheel             0.36.2
xlrd              1.2.0
XlsxWriter        1.1.2
xlwt              1.3.0
zeep              3.2.0
zope.event        4.5.0
zope.interface    5.4.0

Exit the Python virtual environment.

$ deactivate

Configure Odoo

Create a directory for the custom addons.

$ mkdir /opt/odoo/odoo-custom-addons

Switch back to your regular user.

$ exit

Create a configuration file and open it for editing.

$ sudo nano /etc/odoo-server.conf

Edit the file so that it looks like the following.

[options]
; This is the password that allows database operations:
admin_passwd = admin
db_host = postgresql.yourdomain.com
db_port = False
db_user = odoo
db_password = odoo_password
addons_path = /opt/odoo/odoo/addons, opt/odoo/odoo-custom-addons
xmlrpc_port = 8069
logfile = /var/log/odoo/odoo.log

Press Ctrl + X to close the editor and press Y when prompted to save the file.

The option admin_passwd is the password that allows administrative operations within the Odoo GUI. Be sure to choose a secure password.

The option db_host is the FQDN or the IP address of the PostgreSQL server.

The option db_port is set to false since the default PostgreSQL port 5432 is being used. If you want to use a different port, you will need to update this value.

The option db_user is the name of the PostgreSQL user.

The option db_password is the PostgreSQL ‘odoo’ user password we created previously on the PostgreSQL server.

The option addons_path is the default Addons path. You can also add a custom path for addons by separating them with commas.

The option xmlrpc_port is the port that Odoo listens on.

Create Odoo service

To make sure Odoo keeps running even after a system restart, we need to create a service.

Create a file /etc/systemd/system/odoo-server.service and open it for editing.

$ sudo nano /etc/systemd/system/odoo-server.service

Paste the following code in it.

[Unit]
Description=Odoo Open Source ERP and CRM

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

[Install]
WantedBy=multi-user.target

Press Ctrl + X to close the editor and press Y when prompted to save the file.

Reload the system daemon to enable the Odoo service file.

$ sudo systemctl daemon-reload

Set File permissions

Set permissions on the odoo-server.service file so that only the Odoo user can read or execute it.

$ sudo chmod 755 /etc/systemd/system/odoo-server.service
$ sudo chown odoo: /etc/systemd/system/odoo-server.service

Restrict the Odoo configuration file.

$ sudo chown odoo: /etc/odoo-server.conf
$ sudo chmod 640 /etc/odoo-server.conf

Create a log file and change its ownership.

$ sudo mkdir /var/log/odoo
$ sudo touch /var/log/odoo/odoo.log
$ sudo chown -R odoo: /var/log/odoo/

Start the Odoo server

Start and enable the Odoo server.

$ sudo systemctl start odoo-server
$ sudo systemctl enable odoo-server

Check the status of the server.

$ sudo systemctl status odoo-server

In your browser, open the URL http://<yourIPaddress>:8069 or http://odoo.yourdomain.com:8069. If everything is working properly, you should see Odoo’s database creation screen.

Odoo Installer

Fill in all the fields. Check the Demo Data field to populate the database with sample data and then click the Create database button.

Next, it will show you a list of apps that you can choose and select.

The first time you create a database, the addons page will take time to load, so don’t refresh the page.

Install and Configure Nginx

Until now, we have been using Odoo’s server to run the stack. But ideally, it’s better to run it on Nginx using a proxy because that will allow us to install SSL.

Install Nginx.

$ sudo dnf install nginx

To run it via Nginx, we need to run Odoo on localhost. To change that, stop the Odoo service.

$ sudo systemctl stop odoo-server

Open the Odoo server configuration file.

$ sudo nano /etc/odoo-server.conf

Add the following lines to it.

xmlrpc_interface = 127.0.0.1
proxy_mode = True

Create an Nginx configuration file for Odoo.

$ sudo nano /etc/nginx/conf.d/odoo.conf

Paste the code below.

#odoo server
upstream odoo {
 server 127.0.0.1:8069;
}
upstream odoochat {
 server 127.0.0.1:8072;
}

# http -> https
server {
   listen 80;
   server_name odoo.yourdomain.com;
   rewrite ^(.*) https://$host$1 permanent;
}

server {
 listen 443 ssl http2;
 server_name odoo.yourdomain.com;
 proxy_read_timeout 720s;
 proxy_connect_timeout 720s;
 proxy_send_timeout 720s;

 # Add Headers for odoo proxy mode
 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;

 # SSL parameters
 ssl_certificate /etc/letsencrypt/live/odoo.yourdomain.com/fullchain.pem;
 ssl_certificate_key /etc/letsencrypt/live/odoo.yourdomain.com/privkey.pem;
 ssl_session_timeout 1d;
 ssl_session_cache shared:MozSSL:10m;  # about 40000 sessions
 ssl_session_tickets off;
 ssl_protocols TLSv1.2 TLSv1.3;
 ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
 ssl_prefer_server_ciphers off;
 ssl_dhparam /etc/ssl/certs/dhparam.pem;

 # log
 access_log /var/log/nginx/odoo.access.log;
 error_log /var/log/nginx/odoo.error.log;

 # Redirect longpoll requests to odoo longpolling port
 location /longpolling {
 proxy_pass http://odoochat;
 }

 # Redirect requests to odoo backend server
 location / {
   proxy_redirect off;
   proxy_pass http://odoo;
 }

 # common gzip
 gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript;
 gzip on;
}

Press Ctrl + X to close the editor and press Y when prompted to save the file.

Test the Nginx configuration.

$ sudo nginx -t

Install SSL

We will install SSL using Let’s Encrypt service.

For that, install Certbot.

$ sudo dnf install certbot

Stop Nginx because it will interfere with the Certbot process.

$ sudo systemctl stop nginx

Generate the certificate. We also need to create a DHParams certificate.

$ sudo certbot certonly --standalone -d odoo.yourdomain.com --preferred-challenges http --agree-tos -n -m email@yourdomain.com --keep-until-expiring 
$ sudo systemctl start nginx
$ sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048

We also need to set up a cron job for renewing the SSL automatically. To open the crontab editor, run the following command.

$ sudo crontab -e

Paste the following line at the bottom.

25 2 * * * /usr/bin/certbot renew --quiet --pre-hook “systemctl stop nginx” --post-hook “systemctl start nginx”

The above cron job will run certbot at 2:25 am every day. You can change it to anything you want.

Save the file by pressing Ctrl + X and entering Y when prompted.

Start Odoo

Now that everything is set up, we can start the Odoo server again.

$ sudo systemctl start odoo-server

Launch Odoo in your browser via https://odoo.yourdomain.com. You will get a screen described earlier. Enter the required details to create the database, and you should log in to the Odoo and see a screen like this.

Odoo Homepage

Conclusion

This concludes our tutorial on installing Odoo on Fedora 34 server. If you have any questions, post them in the comments below.