Server Preparation & PostgreSQL
Update Ubuntu 24.04, install system dependencies, set up PostgreSQL, create the Odoo database user, and establish the recommended directory layout.
Overview
This chapter starts immediately after your Oracle Cloud VM is created and reachable via SSH, running Ubuntu 24.04 LTS. By the end of this chapter, your server will have a clean package baseline, PostgreSQL installed and running, and a dedicated directory structure for Odoo.
- Oracle Cloud VM running Ubuntu 24.04 LTS
- SSH access to the VM
- A user account with
sudoprivileges
Install Required Packages
Start by updating the package index and upgrading all installed packages to ensure a clean, secure baseline.
sudo apt update sudo apt upgrade -y
Run sudo reboot if the kernel or critical system libraries were upgraded. Reconnect via SSH after the reboot completes.
Install all build dependencies that Odoo's Python packages require during compilation.
sudo apt install -y \
git python3 python3-venv python3-pip \
build-essential gcc g++ \
libxml2-dev libxslt1-dev \
libldap2-dev libsasl2-dev \
libpq-dev libjpeg-dev zlib1g-dev \
node-less npm
Packages like libxml2-dev, libldap2-dev and libpq-dev
are C-level headers required to compile Python wheels for lxml, python-ldap
and psycopg2. Without them, pip install will fail during the Odoo setup step.
Install PostgreSQL
Install PostgreSQL from the official Ubuntu repositories.
sudo apt install -y postgresql
Verify that the service started correctly.
sudo systemctl status postgresql --no-pager
Create the Odoo Database User
Create a dedicated PostgreSQL role named odoo. This role has permission to create
databases (required so Odoo can create and manage its own database), but is not a superuser.
sudo -u postgres createuser -d -R -S odoo
| Flag | Meaning |
|---|---|
-d | Allow the role to create databases |
-R | Prevent the role from creating other roles |
-S | Not a superuser |
This guide intentionally uses local peer authentication via Unix sockets.
Odoo connects to PostgreSQL through a socket, not over TCP/IP, so no password needs to be
stored in odoo.conf. Never expose PostgreSQL directly to the Internet.
Recommended Directory Layout
Create a clean, self-contained directory at /opt/odoo that will hold all Odoo-related files.
Keeping everything under a single directory makes backups, upgrades, and permission management straightforward.
sudo mkdir -p /opt/odoo/{community,enterprise,custom,logs,venv}
sudo chown -R odoo:odoo /opt/odoo/opt/odoo/ ├── community/ ← Odoo Community source (git clone) ├── enterprise/ ← Odoo Enterprise source (git clone) ├── custom/ ← Your custom addons ├── logs/ ← Odoo log files └── venv/ ← Python virtual environment
Keeping custom modules outside the Community and Enterprise repositories makes upgrades much easier. You can pull the latest Community/Enterprise code without touching your customizations.
Verification
Before proceeding to the next chapter, confirm the following.
| Check | Command | Expected Result |
|---|---|---|
| Ubuntu updated | uname -r | Current kernel version |
| Dependencies installed | python3 --version | Python 3.x.x |
| PostgreSQL running | sudo systemctl is-active postgresql | active |
| Odoo DB user created | sudo -u postgres psql -c "\du odoo" | Role listed |
| Directory created | ls /opt/odoo | community, enterprise, custom, logs, venv |
- ✓ Ubuntu updated and optionally rebooted
- ✓ System dependencies installed without errors
- ✓ PostgreSQL is running
- ✓
odooPostgreSQL role exists - ✓
/opt/odoodirectory structure created
The next chapter covers cloning the Community and Enterprise repositories, creating the Python virtual environment, and installing all Python dependencies.