System Architecture and Component Stack
Odoo 18 deployment on Ubuntu 24.04 employs a multi-tier architecture that separates concerns across specialized components. The stack leverages Ubuntu’s native package management alongside Python’s virtual environment isolation. This hybrid approach balances system stability with Odoo’s specific dependency requirements. Understanding this architecture prevents common deployment pitfalls.
The web tier centers around Odoo’s built-in HTTP server with optional Nginx reverse proxy configuration. Odoo 18 handles HTTP requests directly but benefits from Nginx for static asset serving and SSL termination. The application tier runs Python 3.10+ code within a dedicated virtual environment. This isolation prevents conflicts with system Python packages while ensuring Odoo receives exact dependency versions.
The data tier utilizes PostgreSQL 15+ as the exclusive database backend. Odoo maintains persistent connections to PostgreSQL for optimal transaction performance. The system employs connection pooling to manage database resources efficiently. This separation allows independent scaling of application and database components as load increases.
System services coordinate component lifecycle through systemd unit files. The Odoo service runs under a dedicated system user with restricted permissions. This security model follows the principle of least privilege while ensuring proper file access. Log aggregation collects data from all components into centralized locations for monitoring and troubleshooting.
Process Communication Patterns
Odoo processes communicate through well-defined protocols with specific performance characteristics. HTTP requests enter through the web interface and route to appropriate controller methods. The framework uses Python’s multiprocessing to handle concurrent requests with configurable worker processes. Inter-process communication occurs through shared memory for cache and session data.
Long-running operations leverage PostgreSQL’s advisory locks for distributed task coordination. The built-in job queue processes asynchronous tasks through dedicated worker threads. Real-time notifications use WebSocket connections for instant client updates. This multi-channel approach ensures responsive user experience despite backend processing complexity.
Resource Allocation Strategy
Memory allocation follows a calculated formula based on available system RAM and expected concurrent users. Each worker process consumes base memory plus per-request overhead. The system reserves additional memory for PostgreSQL operations and filesystem caching. Proper sizing prevents memory exhaustion under production loads.
CPU resources distribute across worker processes with load balancing at the operating system level. The configuration assigns workers to specific CPU cores to reduce context switching overhead. Disk I/O prioritizes database operations with separate storage volumes for database files and application logs. This separation prevents I/O contention between critical components.
System Preparation and Dependency Installation
Ubuntu 24.04 requires specific package configuration to support Odoo 18’s runtime environment. Begin with a comprehensive system update to ensure all security patches apply. The process installs necessary development tools and Python environment management utilities. These foundational packages enable subsequent Odoo-specific installation steps.
Execute the system preparation commands to establish a clean baseline. Update the package cache and upgrade existing packages to their latest versions. Install essential build tools and libraries that Odoo dependencies require. This preparation prevents compilation failures during Python package installation.
sudo apt update && sudo apt upgrade -y
sudo apt install -y software-properties-common curl wget gnupg2
sudo apt install -y build-essential python3-dev python3-pip python3-venv
sudo apt install -y libxml2-dev libxslt1-dev libsasl2-dev libldap2-dev
sudo apt install -y libssl-dev libpq-dev libjpeg-dev libopenjp2-7-dev
Create the dedicated system user that will run Odoo processes with restricted privileges. This user owns the application files and executes the Odoo server. The security model isolates Odoo from other system services to limit potential attack surface. Configure appropriate home directory permissions for the new user.
sudo useradd -m -d /opt/odoo -U -r -s /bin/bash odoo
PostgreSQL installation requires the official repository to ensure version compatibility with Odoo 18. Ubuntu 24.04’s default PostgreSQL packages may not meet Odoo’s specific version requirements. Add the PostgreSQL global development group repository for access to supported versions. Install both server and client packages with development headers.
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
sudo apt update
sudo apt install -y postgresql-16 postgresql-client-16 postgresql-server-dev-16
Create the PostgreSQL user and database that will serve the Odoo instance. The database user matches the system username for consistency. Configure appropriate database permissions and ownership for the Odoo tables. Set client authentication method to trust for local connections to simplify deployment.
sudo -u postgres createuser --createdb --username postgres --no-createrole --no-superuser --no-password odoo
sudo -u postgres createdb --owner=odoo odoo
Python Environment Configuration
Establish an isolated Python environment using the system’s Python 3.10+ interpreter. The virtual environment contains all Odoo dependencies without affecting system packages. This isolation prevents version conflicts with other Python applications on the server. Activate the environment before installing Odoo requirements.
sudo -u odoo python3 -m venv /opt/odoo/venv
Install Wheel package first to ensure proper binary package installation. This optimization accelerates subsequent dependency installation by compiling C extensions. The process uses pip within the virtual environment to manage all Python packages.
sudo -u odoo /opt/odoo/venv/bin/pip install wheel
Download Odoo 18 source code from the official repository using the specific release branch. This approach ensures version stability compared to development branches. Clone the repository into the Odoo user’s home directory with proper ownership.
sudo -u odoo git clone https://github.com/odoo/odoo.git /opt/odoo/odoo-18 --branch 18.0 --depth 1
Install Odoo Python dependencies from the requirements file using the virtual environment’s pip. This file contains exact version specifications for all necessary packages. The installation process compiles native extensions for optimal performance.
sudo -u odoo /opt/odoo/venv/bin/pip install -r /opt/odoo/odoo-18/requirements.txt
Node.js and Build Tools
Odoo’s web client requires Node.js for asset compilation and management. Install Node.js from the official repositories to ensure version compatibility. The build process uses npm to install frontend dependencies and compile stylesheets.
sudo apt install -y nodejs npm
sudo npm install -g rtlcss
Verify proper installation of all components before proceeding to Odoo configuration. Test Python environment accessibility and PostgreSQL connectivity. Confirm that all system services start without errors.
sudo -u odoo /opt/odoo/venv/bin/python3 --version
sudo -u postgres psql -c "SELECT version();"
Odoo Configuration and Service Setup
Odoo 18 requires careful configuration file setup to define runtime behavior and system integration. Create the main configuration file with appropriate permissions in the Odoo user’s home directory. This file controls database connections, module paths, and server behavior. Use minimal settings for initial deployment with expansion for production requirements.
Create the configuration directory and file with secure permissions. The Odoo user must have read access while preventing unauthorized modification. Set strict file permissions to protect database credentials and other sensitive settings.
sudo mkdir /etc/odoo
sudo touch /etc/odoo/odoo.conf
sudo chown odoo:odoo /etc/odoo/odoo.conf
sudo chmod 640 /etc/odoo/odoo.conf
Populate the configuration file with essential settings for basic operation. Include database connection parameters, addon paths, and logging configuration. These settings establish the foundation for Odoo operation.
[options]
admin_passwd = superadmin_secret_password
db_host = localhost
db_port = 5432
db_user = odoo
db_password = False
addons_path = /opt/odoo/odoo-18/addons
logfile = /var/log/odoo/odoo.log
log_level = info
The admin_passwd parameter secures the database management interface with a strong password. Never use default credentials in production environments. The db_password setting remains False when using peer authentication, which leverages system user identity for database access.
Systemd Service Configuration
Create a systemd service file to manage Odoo as a persistent system service. This approach provides automatic startup, process monitoring, and log integration. The service definition specifies execution environment, user context, and startup parameters.
Create the service file in the systemd directory with proper syntax. Define the service unit with dependency ordering and process management directives. The service should start after PostgreSQL to ensure database availability.
sudo nano /etc/systemd/system/odoo.service
Configure the service with explicit execution paths and user context. The service runs under the Odoo user with the virtual environment activated. Systemd manages process lifecycle and restarts the service on failure.
[Unit]
Description=Odoo 18
After=postgresql.service
[Service]
Type=simple
User=odoo
Group=odoo
ExecStart=/opt/odoo/venv/bin/python3 /opt/odoo/odoo-18/odoo-bin -c /etc/odoo/odoo.conf
KillMode=mixed
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
Create the log directory with proper ownership for Odoo logging. The service writes application logs to this directory for troubleshooting and monitoring. Set appropriate permissions to allow the Odoo user to create log files.
sudo mkdir /var/log/odoo
sudo chown odoo:odoo /var/log/odoo
Enable and start the Odoo service using systemctl commands. Verify successful service startup through status checks and log examination. The service should respond without errors and begin accepting connections.
sudo systemctl enable odoo
sudo systemctl start odoo
sudo systemctl status odoo
Nginx Reverse Proxy Configuration
Configure Nginx as a reverse proxy to handle HTTP requests and serve static files. This setup improves performance and enables SSL termination. Create a new Nginx server block dedicated to Odoo traffic.
Install Nginx from Ubuntu repositories and create the configuration file. The server block proxies dynamic requests to Odoo while serving static files directly. This separation reduces load on the Python application server.
sudo apt install -y nginx
sudo nano /etc/nginx/sites-available/odoo
Define the server block with proxy settings and static file locations. Configure appropriate timeouts and buffer sizes for Odoo’s operation. The setup includes WebSocket proxy support for real-time features.
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://127.0.0.1:8069;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /longpolling {
proxy_pass http://127.0.0.1:8072;
}
location ~* /web/static/ {
proxy_cache_valid 200 60m;
proxy_buffering on;
expires 864000;
proxy_pass http://127.0.0.1:8069;
}
}
Enable the site configuration and test Nginx syntax. Reload Nginx to apply the new configuration. Verify proxy functionality by accessing Odoo through the Nginx server.
sudo ln -s /etc/nginx/sites-available/odoo /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Database Configuration and Optimization
PostgreSQL tuning significantly impacts Odoo performance, especially under concurrent user loads. Ubuntu 24.04’s default PostgreSQL configuration requires adjustment for production Odoo deployments. The tuning process balances memory allocation, connection management, and query optimization.
Modify PostgreSQL’s main configuration file to allocate resources based on available system memory. The shared_buffers setting should allocate approximately 25% of total RAM for database caching. The work_mem parameter controls per-operation memory for sorting and hashing operations. These settings prevent disk-based operations that degrade performance.
Edit the PostgreSQL configuration file to apply performance optimizations. Locate the postgresql.conf file in the PostgreSQL data directory. Adjust memory settings and connection parameters based on your server’s capacity.
sudo nano /etc/postgresql/16/main/postgresql.conf
Apply key performance settings for Odoo workloads. Increase shared buffers for better cache performance and adjust work memory for complex operations. Set effective cache size to help the query planner make better decisions.
shared_buffers = 2GB
work_mem = 32MB
effective_cache_size = 6GB
maintenance_work_mem = 512MB
checkpoint_completion_target = 0.9
wal_buffers = 16MB
default_statistics_target = 500
max_connections = 80
Configure connection pooling with pgBouncer to manage database connections efficiently. Odoo creates persistent database connections that can exhaust PostgreSQL’s connection limits under load. pgBouncer maintains a connection pool and shares connections among multiple Odoo workers.
Install pgBouncer from Ubuntu repositories and configure the pool settings. The pool mode should use transaction pooling for Odoo’s connection pattern. Set appropriate pool sizes based on your Odoo worker configuration.
sudo apt install -y pgbouncer
sudo nano /etc/pgbouncer/pgbouncer.ini
Define the database connection parameters and pool behavior. Configure authentication to match your PostgreSQL setup. The pool configuration should match Odoo’s database connection requirements.
[databases]
odoo = host=localhost port=5432 dbname=odoo
[pgbouncer]
pool_mode = transaction
max_client_conn = 100
default_pool_size = 25
Update Odoo’s configuration to use pgBouncer instead of direct PostgreSQL connections. Change the database host and port to point to the pgBouncer instance. This redirects all database traffic through the connection pool.
db_host = localhost
db_port = 6432
Database Maintenance Strategy
Implement regular database maintenance to prevent performance degradation over time. Schedule vacuum and analyze operations during low-usage periods. These operations update table statistics and reclaim storage from deleted records.
Create a maintenance script that performs essential database operations. The script should run during off-hours to minimize user impact. Include vacuum, reindex, and statistics update commands.
#!/bin/bash
sudo -u postgres vacuumdb --analyze --all
sudo -u postgres reindexdb --all
Configure automated backups to protect against data loss. Use PostgreSQL’s built-in backup tools with appropriate retention policies. Test restoration procedures regularly to ensure backup validity.
sudo -u postgres pg_dump odoo > /backups/odoo-$(date +%Y%m%d).sql
Security Hardening and Access Control
Odoo 18 deployment on Ubuntu 24.04 demands rigorous security measures to protect business data. The configuration must address network exposure, application vulnerabilities, and data protection. A layered security approach minimizes attack surface while maintaining functionality.
Configure firewall rules to restrict access to essential services only. Ubuntu’s UFW firewall provides simple management of iptables rules. Allow only HTTP, HTTPS, and SSH traffic by default. Block all other incoming connections to reduce exposure.
sudo ufw allow ssh
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
Implement fail2ban to protect against brute force attacks on authentication endpoints. Fail2ban monitors log files and automatically blocks IP addresses with suspicious activity. Configure specific jails for Odoo login attempts and PostgreSQL connections.
Install fail2ban and create custom filters for Odoo authentication patterns. The service should detect repeated failed login attempts and implement temporary bans. This protection prevents credential stuffing attacks.
sudo apt install -y fail2ban
sudo nano /etc/fail2ban/jail.local
Define Odoo-specific jails with appropriate ban times and retry limits. The configuration should balance security with legitimate user access. Monitor fail2ban logs to tune detection sensitivity.
[odoo]
enabled = true
port = 8069,8072
filter = odoo
logpath = /var/log/odoo/odoo.log
maxretry = 5
bantime = 3600
Application Security Configuration
Harden Odoo’s security settings through configuration parameters and system-level protections. Enable strong password policies for user accounts. Configure session timeout values to prevent unauthorized access from unattended workstations.
Modify Odoo configuration to implement security best practices. Set appropriate parameters for database filtering and XML-RPC protection. These settings prevent common attack vectors against Odoo instances.
list_db = False
db_filter = ^odoo$
proxy_mode = True
x_sendfile = True
Implement SSL/TLS encryption for all web traffic using Let’s Encrypt certificates. The Certbot tool automates certificate issuance and renewal. Configure Nginx to redirect HTTP traffic to HTTPS endpoints.
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.com
System Hardening Measures
Apply operating system security updates regularly through automated patch management. Configure unattended-upgrades to install security patches without manual intervention. Monitor security advisories for Ubuntu and PostgreSQL vulnerabilities.
sudo apt install -y unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
Configure file system permissions to restrict access to configuration files and data directories. The Odoo user should have minimal privileges required for application operation. Regular security audits verify permission compliance.
sudo chmod 750 /opt/odoo
sudo chmod 640 /etc/odoo/odoo.conf
Performance Monitoring and Optimization
Odoo 18 performance monitoring requires comprehensive metric collection across all system components. The monitoring strategy covers application response times, database performance, and system resource utilization. Proactive monitoring identifies bottlenecks before they impact users.
Implement structured logging with appropriate log levels for different environments. Production systems should use INFO level logging with WARNING for third-party modules. Configure log rotation to prevent disk space exhaustion from growing log files.
Modify Odoo’s logging configuration to capture performance metrics. The log format should include timestamps and request identifiers for correlation. Structured logging enables automated analysis of performance patterns.
log_handler = :INFO
log_db = False
log_level = warn:odoo.addons.auth_signup
Set up system monitoring with Prometheus and Grafana for visualization. The Node Exporter collects system metrics while custom exporters monitor Odoo-specific performance indicators. Grafana dashboards provide real-time visibility into system health.
Install Prometheus node exporter to collect system-level metrics. The exporter provides CPU, memory, disk, and network utilization data. These metrics help correlate Odoo performance with system resource constraints.
sudo apt install -y prometheus-node-exporter
Database Performance Monitoring
Monitor PostgreSQL performance through built-in statistics views and external tools. The pg_stat_statements extension tracks query performance across the database instance. Identify slow queries that require optimization through index creation or query rewriting.
Enable PostgreSQL performance monitoring extensions and configure statistics collection. The setup provides visibility into query execution times and resource consumption. Regular review of these statistics guides performance tuning efforts.
CREATE EXTENSION pg_stat_statements;
Configure Odoo worker processes based on system resources and expected load. The worker calculation formula considers available CPU cores and RAM capacity. Over-provisioning workers causes memory exhaustion while under-provisioning limits concurrency.
Calculate optimal worker count using the standard formula for your hardware. Consider both CPU-bound and I/O-bound operation characteristics. Monitor worker performance and adjust based on actual usage patterns.
workers = 8
max_cron_threads = 2
limit_memory_hard = 2684354560
limit_memory_soft = 2147483648
limit_request = 8192
limit_time_cpu = 600
limit_time_real = 1200
Caching Strategy Implementation
Configure Redis as a caching backend for Odoo sessions and frequently accessed data. Redis caching reduces database load and improves response times for common operations. The cache stores user sessions, translated terms, and computed values.
Install Redis server and configure Odoo to use it for caching. The setup requires proper memory allocation and eviction policies to prevent cache exhaustion. Monitor cache hit rates to measure effectiveness.
sudo apt install -y redis-server
Add Redis configuration to Odoo for session storage and cache management. The setup distributes cache across multiple worker processes while maintaining consistency. Proper cache invalidation ensures data accuracy.
session_redis = True
redis_host = localhost
redis_port = 6379
redis_db = 1
Backup and Disaster Recovery Procedures
Comprehensive backup strategies protect Odoo deployment from data loss and system failures. The backup approach must cover database content, filestore data, and configuration files. A tested restoration procedure ensures business continuity after incidents.
Implement automated database backups using PostgreSQL’s continuous archiving and point-in-time recovery. This method captures all database changes with minimal performance impact. Combine full backups with WAL file archiving for complete data protection.
Configure PostgreSQL archive mode to enable continuous backup operations. The setup requires dedicated storage for archived WAL files and base backups. Monitor archive operations to ensure backup consistency.
wal_level = replica
archive_mode = on
archive_command = 'test ! -f /backups/wal/%f && cp %p /backups/wal/%f'
Schedule regular full database backups during low-usage periods. The backup process should include verification steps to ensure data integrity. Test restoration procedures monthly to validate backup effectiveness.
Create a backup script that performs database dump and filestore synchronization. The script should include error handling and notification for backup failures. Secure backup storage prevents unauthorized access to sensitive business data.
#!/bin/bash
sudo -u odoo pg_dump odoo > /backups/odoo-$(date +%Y%m%d).sql
rsync -av /opt/odoo/odoo-18/filestore /backups/filestore-$(date +%Y%m%d)
System Configuration Backup
Backup Odoo configuration files, custom modules, and system service definitions. These components require protection alongside database content. Version control systems manage custom code changes and configuration revisions.
Store configuration backups in a secure location separate from the production server. The backup set should enable complete system reconstruction in case of catastrophic failure. Document restoration procedures for disaster recovery scenarios.
Implement backup rotation policies to manage storage utilization. Retain daily backups for one week, weekly backups for one month, and monthly backups for one year. This strategy balances storage costs with recovery flexibility.
Monitor backup operations through centralized logging and alerting. Failed backups should trigger immediate notifications to system administrators. Regular backup reports verify protection coverage and identify gaps.
Test disaster recovery procedures through periodic restoration exercises. The tests validate both technical recovery capabilities and operational procedures. Update documentation based on lessons learned from recovery tests.