In today’s fast-paced business world, having an efficient and comprehensive ERP (Enterprise Resource Planning) solution is crucial for success. Odoo, formerly known as OpenERP, is a self-hosted suite of open-source ERP software that offers a wide range of features to streamline and optimize business operations. From customer relationship management and sales pipeline management to project management, manufacturing, invoicing, accounting, and eCommerce, Odoo provides a complete solution for businesses of all sizes.

This tutorial will guide you through the process of installing and configuring Odoo 16 on an Ubuntu 22.04 server. We will cover the prerequisites, installation of dependencies, setting up the PostgreSQL database, configuring Nginx as a reverse proxy, and securing the installation with SSL. By the end of this tutorial, you will have a fully functional Odoo installation ready to empower your business.

Prerequisites

Before we begin the installation process, make sure you have the following prerequisites in place:

  • An Ubuntu 22.04 server: This tutorial assumes that you have a server with Ubuntu 22.04 installed. We will refer to this server as ‘shapehost’.
  • A non-root user with sudo privileges: It’s recommended to create a non-root user with sudo privileges to perform administrative tasks during the installation. You can also use the root user if you prefer.
  • A domain name pointed to the server IP address: For production environments, it’s essential to have a domain name associated with your Odoo installation. This will allow you to access the application securely over the internet.

Step 1: Installing Dependencies

To begin the installation process, we need to install some package dependencies on our Ubuntu system. Since Odoo is mainly written in Python, we also need to install some Python packages. Let’s update the package index first:

sudo apt update

Next, install the necessary package dependencies for Odoo:

sudo apt install git wget python3 build-essential libzip-dev python3-dev libxslt1-dev python3-pip libldap2-dev python3-wheel libsasl2-dev python3-venv python3-setuptools node-less libjpeg-dev xfonts-75dpi xfonts-base libxrender1 libpq-dev libffi-dev fontconfig

During the installation, you may be prompted to confirm the installation. Type ‘y’ and press ENTER to proceed. Once the installation is complete, we can move on to the next step.

Step 2: Installing Node.js

Odoo requires Node.js for generating static files. We will install Node.js 16 from the third-party Nodesource repository. Let’s download and set up the repository:

sudo curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -

After setting up the repository, we can install the Node.js package:

sudo apt install nodejs

Once Node.js is installed, we need to install the ‘rtlcss’ package, which is required for Odoo if you plan to use the right-to-left user interface for specific languages such as Arabic and Hebrew:

sudo npm install -g rtlcss

With Node.js and the necessary packages installed, we can proceed to the next step.

Step 3: Installing Wkhtmltopdf Application

The next dependency we need to install is the Wkhtmltopdf package, which is required by Odoo for rendering HTML pages to PDF and various image formats. We will download and install the package manually via the .deb file. Let’s download the .deb file first:

cd /tmp
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb

Once the file is downloaded, we can install the Wkhtmltopdf package:

sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb

If you encounter any errors related to missing dependencies, you can fix them by running the following command:

sudo apt install -f

After the installation is complete, we can verify the installation by checking the availability of the Wkhtmltopdf binary files:

ls /usr/local/bin

You should see the ‘wkhtmltopdf’ and ‘wkhtmltoimage’ programs listed. Additionally, let’s ensure that the binary path for the Wkhtmltopdf package is available:

which wkhtmltopdf
which wkhtmltoimage

If both commands return the full path of the Wkhtmltopdf package, then the installation was successful. We are now ready to move on to the next step.

Step 4: Installing PostgreSQL Database Server

Odoo supports multiple databases, including MySQL, SQLite, and PostgreSQL. In this tutorial, we will use PostgreSQL as the default database for our Odoo installation. Let’s start by installing the PostgreSQL database server:

sudo apt install postgresql

Once the installation is complete, we can verify the status of the PostgreSQL service:

sudo systemctl is-enabled postgresql
sudo systemctl status postgresql

Make sure that the service is enabled and running. If everything looks good, we can proceed to create a new role for Odoo.

Step 5: Creating a PostgreSQL Role for Odoo

We need to create a new role in PostgreSQL specifically for our Odoo installation. This role will have the necessary privileges to interact with the database. Let’s log in as the ‘postgres’ user and create the role:

su - postgres
createuser -sdP odoo

You will be prompted to enter a password for the new role ‘odoo’. Choose a secure password and remember it. After creating the role, we need to log in to the PostgreSQL shell to verify the list of roles:

psql

Inside the PostgreSQL shell, run the following query to list the roles:

du

You should see the role ‘odoo’ listed. Type ‘q’ to exit the PostgreSQL shell, and then type ‘exit’ to log out from the ‘postgres’ user.

Now that we have created the role for Odoo, we need to set up authentication for this role. Let’s edit the PostgreSQL configuration file:

sudo nano /etc/postgresql/14/main/pg_hba.conf

Add the following configuration to the file, which allows access to PostgreSQL for the ‘odoo’ role using password authentication:

host all odoo 127.0.0.1/32 scram-sha-256

Save the file and exit the editor. Next, restart the PostgreSQL service to apply the new changes:

sudo systemctl restart postgresql

To verify that the ‘odoo’ role is set up correctly, let’s log in as the ‘postgres’ user and access the PostgreSQL shell using the ‘odoo’ role:

su- postgres
psql -h 127.0.0.1 -U odoo -d postgres

Once logged in, run the following query to check the connection information:

conninfo

You should see that you are connected to PostgreSQL using the ‘odoo’ role. If everything is working as expected, we can proceed to the next step.

Step 6: Downloading Odoo 16 Source Code

Now that we have set up the necessary dependencies and configured PostgreSQL, we can proceed to download the Odoo 16 source code. We will create a new Unix user ‘odoo’ and download the source code into the user’s home directory. Let’s create the user:

sudo adduser --system --group --home=/opt/odoo --shell=/bin/bash odoo

Next, change to the ‘/opt/odoo’ directory and clone the Odoo 16 source code from the official repository:

cd /opt/odoo
git clone https://github.com/odoo/odoo.git --depth1 --branch16.0 --single-branch odoo-server

After the cloning process is complete, change the ownership of the source code directory to the ‘odoo’ user:

sudo chown -R odoo:odoo /opt/odoo/odoo-server

We have now downloaded the Odoo 16 source code, and we are ready to proceed to the next step.

Step 7: Installing Python Dependencies for Odoo

Before we can run Odoo, we need to set up a Python virtual environment and install the necessary Python dependencies. Let’s navigate to the Odoo source code directory and create a new Python virtual environment:

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

Activate the virtual environment:

source venv/bin/activate

You should see that your shell prompt has changed to indicate that you are now working within the virtual environment. Now let’s install the Python package ‘wheel’ and the required Python dependencies for Odoo using the ‘requirements.txt’ file:

pip3 install wheel
pip3 install -r requirements.txt

Once the installation is complete, exit the virtual environment:

deactivate

We have now installed all the Python dependencies for Odoo. Let’s move on to the next step.

Step 8: Creating Odoo Configuration

Now that we have completed the installation of dependencies and Python packages, we need to create a configuration file for Odoo. This file will contain the necessary settings for running Odoo. Let’s create the configuration file:

sudo nano /etc/odoo.conf

Add the following configuration to the file, replacing the placeholder values with your own details:

[options]
admin_passwd = adminpass
odoodb_host = 127.0.0.1
db_port = 5432
db_user = odoo
db_password = odoopass
addons_path = /opt/odoo/odoo-server/addons
xmlrpc_port = 8069
logfile = /var/log/odoo/odoo-server.log
log_level = debug

Save the file and exit the editor. Next, change the ownership of the configuration file to the ‘odoo’ user:

sudo chown odoo:odoo /etc/odoo.conf

Now let’s create a log directory for Odoo:

sudo mkdir /var/log/odoo

Change the ownership of the log directory to the ‘odoo’ user and set the appropriate permissions:

sudo chown odoo:odoo /var/log/odoo
sudo chmod 755 /var/log/odoo

We have now created the configuration file and set up the log directory for Odoo. Let’s move on to the next step.

Step 9: Running Odoo as a Systemd Service

To make it easier to manage and control Odoo, we can set it up as a systemd service. This will allow us to start, stop, and restart Odoo using the systemctl command. Let’s create a new systemd service file for Odoo:

sudo nano /lib/systemd/system/odoo-server.service

Add the following configuration to the file:

[Unit]
Description=Odoo 16.0 Service
Requires=postgresql.service
After=network.target postgresql.service

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

[Install]
WantedBy=multi-user.target

Save the file and exit the editor. Next, reload the systemd manager to apply the new service file:

sudo systemctl daemon-reload

Start the Odoo service and enable it to start automatically at system startup:

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

Finally, let’s verify the status of the Odoo service to ensure that it is running:

sudo systemctl status odoo-server

If everything is working correctly, you should see the status of the ‘odoo-server’ service as ‘running’. We have now successfully set up Odoo as a systemd service. Let’s move on to the next step.

Step 10: Running Odoo with Nginx Reverse Proxy

To secure our Odoo installation and enable access over the internet, we will set up Nginx as a reverse proxy. This will allow us to run Odoo only on the localhost and have Nginx handle client requests. Additionally, we will secure the installation with SSL using Let’s Encrypt certificates. Before we proceed, make sure you have a domain name pointed to your server’s IP address and have generated SSL certificates for your domain.

Let’s start by modifying the Odoo configuration file to enable proxy mode:

sudo nano /etc/odoo.conf

Add the following configuration to the file:

xmlrpc_interface = 127.0.0.1
proxy_mode = True

Save the file and exit the editor. Next, restart the Odoo service to apply the changes:

sudo systemctl restart odoo-server

Verify that the Odoo service is running:

sudo systemctl status odoo-server

Now let’s install and configure Nginx as a reverse proxy for our Odoo installation. First, install the Nginx package:

sudo apt install nginx

After the installation is complete, create a new Nginx server block configuration file:

sudo nano /etc/nginx/sites-available/odoo.conf

Add the following configuration to the file, replacing the domain name and SSL certificate paths with your own details:

# Odoo server
upstream odoo {
server 127.0.0.1:8069;
}

# Odoo chat
upstream odoochat {
server 127.0.0.1:8072;
}

# HTTP -> HTTPS redirection
server {
listen 80;
server_name example.io;
rewrite ^(.*) https://$host$1 permanent;
}

# HTTPS server block
server {
listen 443 ssl http2;
server_name example.io;

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/example.io/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.io/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
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;

# Log files
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;
}
sudo ln -s /etc/nginx/sites-available/odoo.conf /etc/nginx/sites-enabled/
sudo nginx -t

If there are no syntax errors in the configuration, restart the Nginx service to apply the changes:

sudo systemctl restart nginx

Congratulations! You have now successfully set up Nginx as a reverse proxy for your Odoo installation. You can access your Odoo installation by visiting your domain name in a web browser.

Step 11: Setting up UFW Firewall

To enhance the security of your Odoo installation, it’s recommended to enable the UFW firewall. UFW (Uncomplicated Firewall) is a user-friendly interface for managing firewall rules on Ubuntu. Let’s start by allowing SSH connections:

sudo ufw allow "OpenSSH"

Next, enable the UFW firewall:

sudo ufw enable

When prompted for confirmation, type ‘y’ and press ENTER. The UFW firewall service will be enabled and running. Now let’s add the ‘Nginx Full’ application profile to allow both HTTP and HTTPS traffic:

sudo ufw allow "Nginx Full"

To verify the list of enabled rules on UFW, run the following command:

sudo ufw status

You should see the rules for ‘OpenSSH’ and ‘Nginx Full’ listed as enabled. Your Odoo installation is now protected by the UFW firewall.

Step 12: Migrating Database and Installing Odoo 16

With all the setup and configuration completed, it’s time to migrate the database and install Odoo 16. Open your web browser and visit your Odoo domain name (e.g., https://example.io/). You will be redirected to the Odoo installation page.

To start the installation process, follow these steps:

  1. Specify a new database name: Enter a name for your new Odoo database. This name will be automatically created.
  2. Set up the administrator user: Enter the details for the new administrator user, including the email address and password.
  3. (Optional) Enable demo data: If you want to include demo data in your installation, check the “Load demonstration data” checkbox.
  4. Click on the “Create database” button to start the Odoo installation.

Once the installation is complete, you will be redirected to the Odoo login page. Enter the admin email and password you specified earlier to log in to your Odoo dashboard.

Congratulations! You have successfully installed Odoo 16 on your Ubuntu 22.04 server. You now have a powerful ERP solution at your fingertips to streamline and optimize your business operations.

Conclusion

In this tutorial, we have covered the step-by-step process of installing and configuring Odoo 16 on an Ubuntu 22.04 server. We started by installing the necessary dependencies, setting up the PostgreSQL database, configuring Nginx as a reverse proxy, and securing the installation with SSL. By following these steps, you have created a robust and secure environment for your Odoo ERP system.

Now that you have Odoo up and running, you can start exploring its vast range of features and modules to tailor it to your specific business needs. From customer relationship management and project management to manufacturing, invoicing, accounting, and eCommerce, Odoo offers a comprehensive suite of tools to help you streamline your business processes and boost productivity.

If you’re looking for reliable and high-performance hosting solutions for your Odoo installation, consider Shape.host’s Linux SSD VPS services. Shape.host offers scalable and secure cloud hosting solutions, ensuring optimal performance and uptime for your Odoo ERP system. With Shape.host, you can focus on growing your business while leaving the hosting infrastructure to the experts.