How to Install Odoo 19 on Ubuntu 24.04 with Nginx and Let’s Encrypt SSL

Deploying Odoo on the latest Ubuntu 24.04 LTS provides a modern, secure foundation for your ERP. However, since Ubuntu 24.04 uses Python 3.12 and has updated library structures, the installation requires a specific approach.

In this guide, we will walk through the step-by-step process of setting up Odoo as a system service, configuring Nginx as a reverse proxy, and securing it with a free SSL certificate.

Prerequisites

  • A server running Ubuntu 24.04.
  • A user with sudo privileges (we’ll use the default ubuntu user).
  • A registered Domain Name pointing to your server’s IP address.

Step 1: Update System and Install Dependencies

First, ensure your system is up to date and install the necessary Python build tools and libraries.

sudo apt update && sudo apt upgrade -y
sudo apt install libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev libjwk-dev libpq-dev libjpeg-dev xfonts-75dpi xfonts-base libxrender1 -y

Step 2: Install and Configure PostgreSQL

Odoo uses PostgreSQL as its database backend. We will create a database user that matches our system username to simplify authentication.

sudo apt install postgresql postgresql-client -y
sudo systemctl start postgresql
sudo systemctl enable postgresql

# Create a database user (replace 'ubuntu' if your username is different)
sudo -u postgres createuser -s $USER
createdb odoo-db

Step 3: Install Wkhtmltopdf (The Patched Version)

Odoo requires wkhtmltopdf to generate PDF reports. Ubuntu 24.04 doesn’t provide the “patched-qt” version in its default repo, so we install the 22.04 build, which is compatible.

cd /tmp
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo apt --fix-broken install -y

Step 4: Set Up Odoo Dependencies

First, clone the Odoo 19 from the official git repo. Then run the debinstall.sh to install the dependencies

# Create directory and clone Odoo (replace 19.0 with your preferred version)
cd ~/
git clone --branch 19.0 --single-branch --depth 1 https://github.com/odoo/odoo.git
# Install Odoo Python dependencies
sudo ./odoo/setup/debinstall.sh

Step 5: Configure Odoo and Systemd Service

Create a configuration file to store your database and path settings.

1. Create the Config File

nano ~/odoo/odoo.conf

[options]
admin_passwd = YOUR_STRONG_@MASTER_PASSW1ORD
db_host = False
db_port = False
db_user = ubuntu
db = odoo-db
db_password = False
addons_path = /home/ubuntu/odoo/addons,/home/ubuntu/odoo/odoo/addons
proxy_mode = True

Then run the db initialization.

cd ~
./odoo/odoo-bin -c odoo.conf -d odoo-db -i base

2. Create the Systemd Service

This ensures Odoo starts automatically when the server reboots.

sudo nano /etc/systemd/system/odoo.service

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

[Service]
Type=simple
User=ubuntu
Group=ubuntu
WorkingDirectory=/home/ubuntu/odoo
ExecStart=python3 /home/ubuntu/odoo/odoo-bin -c /home/ubuntu/odoo/odoo.conf
Restart=always

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now odoo

Step 6: Configure Nginx as a Reverse Proxy

Nginx will handle incoming traffic on port 80/443 and pass it to Odoo on port 8069.

sudo apt install nginx -y
sudo nano /etc/nginx/sites-available/odoo

Paste this configuration (replace yourdomain.com):

upstream odoo { server 127.0.0.1:8069; }

server {
    listen 80;
    server_name erp.atiqur.xyz;
    proxy_read_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;

    location / { proxy_pass http://odoo; }
}

sudo ln -s /etc/nginx/sites-available/odoo /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
sudo nginx -t && sudo systemctl restart nginx

Step 7: Secure with Let’s Encrypt SSL

Finally, we use Certbot to fetch and install an SSL certificate automatically.

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx 

Follow the prompts, and choose the option to Redirect all HTTP traffic to HTTPS.

Optimize the PostgreSQL database for better Odoo performance

1. Calculate Your Resources

PostgreSQL performance depends heavily on the amount of RAM you allocate to it. A good rule of thumb for an Odoo-dedicated server is to allocate about 25% to 40% of your total system RAM to PostgreSQL.

2. Edit the PostgreSQL Configuration

Open the configuration file (replace 16 with your version if different, though Ubuntu 24.04 typically ships with 16):

sudo nano /etc/postgresql/16/main/postgresql.conf

Find and update these specific parameters:

  • shared_buffers: Set this to 25% of your total RAM (e.g., 2GB for an 8GB server).
  • effective_cache_size: Set this to 75% of your total RAM. This helps the query planner decide if an index will fit in memory.
  • work_mem: Set to 64MB. This is the memory used for internal sort operations and hash tables.
  • maintenance_work_mem: Set to 256MB. This speeds up vacuuming and index creation.
  • max_connections: For Odoo, 100200 It is usually plenty.

3. Enable Huge Pages (Optional but Recommended)

For servers with more than 16GB of RAM, enabling “Huge Pages” in Linux can reduce memory management overhead.

4. Restart to Apply Changes

After saving the file, restart PostgreSQL:

sudo systemctl restart postgresql

Final Health Check: The “Odoo Log”

Since you are now running as a service, if anything feels slow or isn’t working, your best friend is the log file we defined in the .conf file earlier.

You can watch it in real-time to see if PostgreSQL is struggling with “Slow Queries”:

tail -f /home/ubuntu/odoo/odoo.log

Conclusion

Your Odoo instance is now live, secured with SSL, and managed as a system service. You can access it by visiting https://yourdomain.com.

Next Step: Log in to your Odoo instance and immediately create your first database. The “Master Password” you set in Odoo.conf A file will be required for this step!

Atiqur Rahman

I am MD. Atiqur Rahman graduated from BUET and is an AWS-certified solutions architect. I have successfully achieved 6 certifications from AWS including Cloud Practitioner, Solutions Architect, SysOps Administrator, and Developer Associate. I have more than 8 years of working experience as a DevOps engineer designing complex SAAS applications.

Leave a Reply