System Architecture and Component Integration
Odoo 18 operates on a multi-tier architecture that separates presentation, application, and data layers. The web interface connects through a Python application server to a PostgreSQL database backend. This modular design supports horizontal scaling and high availability configurations. Each component requires specific resource allocation and security considerations.
The presentation layer utilizes QWeb templates rendered by the Odoo server’s HTTP service. Browser requests route through a reverse proxy like Nginx, which handles SSL termination and static file serving. This separation improves security and reduces load on the application server. The proxy configuration determines how external clients access your Odoo instance.
The application layer consists of the Odoo server written in Python, executing business logic and processing requests. This server manages module loading, database connections, and session handling. It interfaces with the PostgreSQL database through Python database adapters. The application server’s configuration parameters control performance characteristics and resource limits.
The data layer centers on PostgreSQL, storing all operational data, user information, and system configurations. Odoo maintains database connections through connection pooling to manage concurrent requests. Proper database configuration ensures data integrity and transaction consistency. The database server requires regular maintenance tasks like vacuuming and backup operations.
Component communication follows specific protocols with defined data exchange patterns. HTTP/HTTPS protocols handle web requests between clients and the application server. The application server uses PostgreSQL’s native protocol for database communications. Internal process communication occurs through multiprocessing queues and shared memory segments.
Prerequisites and System Preparation
Ubuntu 20.04 LTS provides the foundation for your Odoo deployment with long-term support stability. The operating system requires current security patches and necessary system updates. You need a non-root user account with sudo privileges for administrative tasks. The system should have minimum 2GB RAM and 20GB disk space for basic operation.
Execute system updates to ensure all existing packages have the latest security fixes. The apt update command refreshes your package repository information. The apt upgrade command installs available updates for installed packages. This preparation prevents conflicts between system libraries and Odoo dependencies.
sudo apt update
sudo apt upgrade -y
Create a dedicated system user account for Odoo processes to improve security isolation. This user owns the Odoo application files and runs the server processes. The dedicated account limits potential security breaches to the Odoo environment. Use the adduser command with specific home directory and shell parameters.
sudo adduser --system --group --home /opt/odoo --shell /bin/bash odoo
Install Python dependencies and development tools required for Odoo operation. Python 3.8 serves as the primary runtime environment for Odoo 18. The build-essential package provides compilation tools for native Python packages. Additional libraries support database connectivity and XML processing.
sudo apt install -y python3-pip python3-dev python3-venv python3-wheel
sudo apt install -y build-essential libpq-dev libxslt-dev libldap2-dev libsasl2-dev
Install and configure PostgreSQL database server to host Odoo data. The database server requires proper memory configuration and connection settings. Create a dedicated PostgreSQL user that matches your Odoo system user. This alignment simplifies database authentication and permission management.
sudo apt install -y postgresql postgresql-contrib
sudo -u postgres createuser --createdb --username postgres --no-createrole --no-superuser --no-password odoo
PostgreSQL Database Configuration
PostgreSQL requires specific configuration adjustments to support Odoo’s operational patterns. The postgresql.conf file controls database engine parameters like memory allocation and connection limits. The pg_hba.conf file manages client authentication methods and network access rules. These configurations impact both performance and security characteristics.
Set appropriate shared_buffers allocation based on your available system memory. This parameter determines how much memory PostgreSQL dedicates to caching data. Allocate approximately 25% of total system RAM to shared_buffers for optimal performance. The work_mem parameter controls the amount of memory available for sorting operations.
sudo nano /etc/postgresql/12/main/postgresql.conf
# Adjust the following parameters:
# shared_buffers = 512MB
# work_mem = 10MB
# max_connections = 80
Configure client authentication to secure database access from the Odoo application. The pg_hba.conf file defines which users can connect from which hosts using which authentication methods. Use md5 authentication for local connections to require password verification. Restrict database access to only the necessary system accounts.
sudo nano /etc/postgresql/12/main/pg_hba.conf
# Add line for Odoo user:
# local all odoo md5
Create the initial Odoo database using the dedicated database user. The createdb command initializes the database cluster with proper locale settings. Specify database encoding and template parameters to ensure compatibility with Odoo requirements. The database name should reflect your deployment purpose and environment.
sudo -u postgres createdb --owner=odoo odoo-prod
Configure database connection pooling to improve performance under concurrent user loads. PgBouncer or similar connection poolers manage database connections more efficiently than the application server. This approach reduces connection overhead and improves response times during peak usage. Connection pooling prevents database connection exhaustion errors.
Test database connectivity using the psql command-line interface. Verify that the Odoo system user can connect to the database using password authentication. Confirm proper permissions for database creation and schema modification operations. These tests validate your authentication configuration before proceeding with Odoo installation.
sudo -u odoo psql -d odoo-prod
Odoo Application Installation and Configuration
Download the Odoo 18 source code from the official repository using Git version control. This approach provides better control over version management and future updates. The Git clone command retrieves the specific branch containing Odoo 18 code. Place the source code in the Odoo user’s home directory with proper ownership.
sudo -u odoo git clone https://github.com/odoo/odoo.git --branch 18.0 --depth 1 /opt/odoo/odoo-server
Create a Python virtual environment to isolate Odoo dependencies from system packages. The venv module creates an independent Python environment with separate package installation. This isolation prevents conflicts with system Python packages and other applications. Activate the virtual environment before installing Python dependencies.
sudo -u odoo python3 -m venv /opt/odoo/odoo-venv
source /opt/odoo/odoo-venv/bin/activate
Install Python dependencies using the requirements.txt file from the Odoo source code. The pip package manager resolves and installs all necessary Python libraries for Odoo operation. Some packages require native compilation using the build tools installed during system preparation. This process may take several minutes to complete.
sudo -u odoo /opt/odoo/odoo-venv/bin/pip3 install -r /opt/odoo/odoo-server/requirements.txt
Create the Odoo configuration file with parameters tailored to your deployment environment. The odoo.conf file controls server behavior, database connections, and module paths. Use secure values for database passwords and secret keys. The configuration file determines how Odoo interacts with the operating system and database.
sudo mkdir /etc/odoo
sudo nano /etc/odoo/odoo.conf
The configuration file contains critical parameters for production deployment. Set the admin password using a strong random value to secure database operations. Specify the addons path to include both core modules and custom developments. Configure logging parameters to capture operational data without consuming excessive disk space.
[options]
admin_passwd = your_strong_password_here
db_host = localhost
db_port = 5432
db_user = odoo
db_password = False
addons_path = /opt/odoo/odoo-server/addons
logfile = /var/log/odoo/odoo-server.log
log_level = info
Create necessary directories for Odoo operation with proper permissions. The log directory stores server logs for troubleshooting and monitoring. The custom addons directory hosts organization-specific modules and customizations. These directories require write permissions for the Odoo system user.
sudo mkdir /var/log/odoo
sudo chown odoo:odoo /var/log/odoo
sudo mkdir /opt/odoo/custom-addons
sudo chown odoo:odoo /opt/odoo/custom-addons
Create a systemd service file to manage Odoo as a system service. The service file defines how the operating system starts, stops, and monitors the Odoo process. This approach ensures Odoo starts automatically after system reboots. The service file specifies the execution environment and resource limits.
sudo nano /etc/systemd/system/odoo.service
The systemd service file contains the complete execution context for Odoo. It specifies the user account, working directory, and execution command. The service file also defines restart behavior and dependency ordering. Proper service configuration ensures reliable operation in production environments.
[Unit]
Description=Odoo 18
After=postgresql.service
[Service]
Type=simple
User=odoo
Group=odoo
ExecStart=/opt/odoo/odoo-venv/bin/python3 /opt/odoo/odoo-server/odoo-bin -c /etc/odoo/odoo.conf
KillMode=mixed
Restart=always
[Install]
WantedBy=multi-user.target
Nginx Reverse Proxy Configuration
Nginx functions as a reverse proxy that handles client connections and forwards requests to Odoo. This architecture improves security by isolating the application server from direct internet access. Nginx manages SSL termination, static file serving, and request buffering. The reverse proxy configuration determines how users access your Odoo instance.
Install Nginx using the Ubuntu package manager to ensure compatibility with system libraries. The nginx package provides a high-performance web server capable of handling concurrent connections. The installation includes necessary service management integration with systemd. Verify the installation completes without errors.
sudo apt install -y nginx
Create an Nginx server block configuration specific to your Odoo deployment. The server block defines the domain name, SSL settings, and proxy parameters. This configuration separates Odoo traffic from other web services on the same server. The server block file resides in the Nginx sites-available directory.
sudo nano /etc/nginx/sites-available/odoo
The Nginx configuration includes specific directives for optimal Odoo operation. The proxy_set_header directives preserve client information through the proxy chain. The location blocks separate static content handling from dynamic request processing. Buffer size parameters prevent memory exhaustion during large file uploads.
server {
listen 80;
server_name your-domain.com;
# Odoo log files
access_log /var/log/nginx/odoo-access.log;
error_log /var/log/nginx/odoo-error.log;
# Proxy settings
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
# Odoo server
location / {
proxy_pass http://127.0.0.1:8069;
proxy_redirect off;
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;
}
# Static files
location /web/static/ {
alias /opt/odoo/odoo-server/odoo/addons/web/static/;
expires 1y;
add_header Cache-Control public;
}
}
Enable the Nginx server block configuration by creating a symbolic link. The link connects the configuration file from sites-available to sites-enabled directory. This approach allows quick configuration activation and deactivation. Test the Nginx configuration syntax before applying changes.
sudo ln -s /etc/nginx/sites-available/odoo /etc/nginx/sites-enabled/odoo
sudo nginx -t
sudo systemctl reload nginx
Configure Odoo to recognize proxy headers for proper URL generation. The proxy_mode parameter in the Odoo configuration file enables reverse proxy support. This setting ensures Odoo generates correct URLs when behind a reverse proxy. Without this configuration, Odoo may generate incorrect links using internal port numbers.
proxy_mode = True
x_forwarded_for = True
SSL Certificate Implementation with Let’s Encrypt
SSL encryption secures data transmission between clients and your Odoo instance. Let’s Encrypt provides free SSL certificates through an automated validation process. The Certbot tool automates certificate issuance and installation with Nginx integration. SSL implementation protects sensitive business data and user credentials.
Install Certbot and the Nginx plugin using the Ubuntu package repository. The certbot package provides the core certificate management functionality. The python3-certbot-nginx package enables automatic Nginx configuration integration. These tools simplify the certificate issuance and renewal process.
sudo apt install -y certbot python3-certbot-nginx
Obtain an SSL certificate for your domain using the Certbot Nginx plugin. The certificate issuance process requires domain validation through HTTP challenges. Certbot automatically modifies your Nginx configuration to serve the validation files. Successful validation results in certificate issuance and automatic configuration.
sudo certbot --nginx -d your-domain.com
Certbot creates a renewed SSL configuration in your Nginx server block. The configuration includes redirects from HTTP to HTTPS and optimal SSL settings. The ssl_certificate directives point to the issued certificate and private key files. Certbot enables modern TLS protocols and disables insecure encryption ciphers.
Configure automatic certificate renewal to maintain continuous SSL protection. Let’s Encrypt certificates have a 90-day validity period requiring regular renewal. The certbot renewal command checks certificate expiration and performs renewals when necessary. Systemd timers or cron jobs automate the renewal process.
sudo systemctl enable certbot.timer
sudo systemctl start certbot.timer
Test the certificate renewal process without actually performing a renewal. The dry run option validates the renewal configuration without consuming rate limits. This verification ensures your renewal process works correctly before certificates approach expiration. Address any configuration issues identified during the test.
sudo certbot renew --dry-run
Verify SSL configuration using online testing tools like SSL Labs. These tools analyze your SSL implementation for potential security vulnerabilities. The tests validate certificate chain completeness, protocol support, and cipher strength. Address any identified issues to maintain strong security posture.
Security Hardening and Access Controls
Odoo deployments require specific security measures to protect business data and system integrity. The security configuration spans multiple layers including network access, application permissions, and database security. Each layer implements defense-in-depth principles to create a resilient security posture. Proper security hardening prevents unauthorized access and data breaches.
Configure firewall rules to restrict network access to essential services only. Ubuntu’s UFW firewall management tool simplifies rule creation and management. Allow SSH access for administration and HTTP/HTTPS for application access. Block all other incoming connections by default to reduce attack surface.
sudo ufw allow ssh
sudo ufw allow 'Nginx Full'
sudo ufw enable
Secure the Odoo configuration file with strict permissions to prevent unauthorized access. The configuration contains database credentials and security parameters that require protection. Set file ownership to the Odoo user and restrict read access to necessary system accounts. This precaution prevents credential leakage through configuration file exposure.
sudo chown odoo:odoo /etc/odoo/odoo.conf
sudo chmod 640 /etc/odoo/odoo.conf
Implement strong password policies for Odoo user accounts and database access. The admin_passwd parameter in the Odoo configuration controls database management operations. Use a complex random password for this parameter to prevent unauthorized database operations. Encourage users to create strong passwords through Odoo’s password policy settings.
Configure Odoo’s built-in security features for enhanced protection. The list_db parameter prevents database enumeration through the web interface. The database manager interface should remain disabled in production environments. These settings reduce information disclosure that attackers could exploit.
list_db = False
dbfilter = ^your-db-name-.*$
Regularly update Odoo and system packages to address security vulnerabilities. The Ubuntu package manager provides security updates for the operating system and installed packages. The pip package manager updates Python dependencies in the virtual environment. Establish a patch management process to apply security updates promptly.
sudo apt update && sudo apt upgrade
sudo -u odoo /opt/odoo/odoo-venv/bin/pip3 install --upgrade -r /opt/odoo/odoo-server/requirements.txt
Implement file integrity monitoring to detect unauthorized system changes. Tools like AIDE or Tripwire create baselines of critical system files and alert on modifications. Monitor the Odoo source code, configuration files, and system binaries for unexpected changes. This detection capability provides early warning of potential security incidents.
Backup and Disaster Recovery Procedures
A comprehensive backup strategy protects your Odoo investment against data loss and system failures. The backup approach must address both database content and file storage elements. Regular backups enable recovery from accidental deletions, corruption, or security incidents. Test your backup restoration process to verify recovery capability.
Create automated database backups using PostgreSQL’s native dump functionality. The pg_dump command creates consistent snapshots of the database while it remains operational. Schedule regular backups using cron jobs with appropriate retention policies. Store backups in secure locations separate from the production server.
sudo -u postgres pg_dump odoo-prod > /backup/odoo-db-$(date +%Y%m%d).sql
Implement filesystem backups for critical Odoo directories and configuration files. The filestore directory contains document attachments that the database references. The custom addons directory stores organization-specific modules and customizations. Configuration files preserve system settings and integration parameters.
sudo tar -czf /backup/odoo-filestore-$(date +%Y%m%d).tar.gz /opt/odoo/odoo-server/.local/share/Odoo/filestore/
Automate backup operations using scheduled cron jobs with proper error handling. The cron scheduler executes backup scripts at defined intervals without manual intervention. Include notification mechanisms to alert administrators of backup failures. Log backup operations for audit purposes and troubleshooting.
# Add to crontab
0 2 * * * /usr/local/bin/backup-odoo.sh
Develop a comprehensive disaster recovery plan documenting restoration procedures. The plan should address various failure scenarios from single component failures to complete site loss. Include step-by-step recovery instructions with estimated timeframes for each scenario. Test the recovery process periodically to maintain readiness.
Implement backup verification procedures to ensure backup integrity and usability. Regular restoration tests validate that backups contain recoverable data. Checksum verification confirms backup file integrity during storage and transfer. Monitoring systems should alert administrators to backup verification failures.
Configure backup retention policies that balance storage costs with business requirements. Daily backups might retain for 30 days, weekly backups for three months, and monthly backups for one year. The retention policy should comply with organizational data governance requirements. Automate backup rotation to enforce retention policies consistently.
Monitor backup system health through automated checks and alerting. Verify backup completion, file sizes, and storage availability daily. Implement alerting for backup failures, storage capacity issues, or verification problems. Proactive monitoring prevents backup system degradation that could compromise recovery capability.
Performance Optimization and Monitoring
Odoo performance optimization requires attention to multiple system components and configuration parameters. The database layer, application server, and reverse proxy each present optimization opportunities. Proper tuning ensures responsive user experience under expected workload volumes. Performance monitoring identifies bottlenecks and guides optimization efforts.
Configure PostgreSQL performance parameters based on available system resources. The shared_buffers setting controls how much memory PostgreSQL allocates for caching data. The effective_cache_size parameter helps the query planner make better index usage decisions. The work_mem setting influences sort operations and hash table sizes.
# In postgresql.conf
shared_buffers = 1GB
effective_cache_size = 3GB
work_mem = 10MB
maintenance_work_mem = 256MB
Optimize Odoo server parameters to balance memory usage and performance. The workers parameter controls how many simultaneous requests the Odoo server can process. The limit_memory_soft and limit_memory_hard parameters prevent memory exhaustion from individual requests. These settings prevent out-of-memory errors while maintaining responsiveness.
# In odoo.conf
workers = 4
limit_memory_soft = 1073741824
limit_memory_hard = 2147483648
limit_request = 8192
limit_time_cpu = 60
limit_time_real = 120
Implement caching strategies to reduce database load and improve response times. The Odoo ORM includes internal caching mechanisms for frequently accessed data. Nginx can cache static content and even dynamic responses for anonymous users. Redis or Memcached integration provides distributed caching for multi-worker deployments.
Configure monitoring to track system performance and identify degradation trends. The Odoo built-in performance metrics provide application-level insight into request processing times. System monitoring tools track resource utilization like CPU, memory, and disk I/O. Database monitoring identifies slow queries and indexing opportunities.
# Install monitoring tools
sudo apt install -y htop iotop nmon
Set up log aggregation and analysis to identify performance patterns and errors. Centralized logging collects data from Odoo, PostgreSQL, and Nginx into a single location. Log analysis tools identify error frequency, slow requests, and usage patterns. Automated alerting notifies administrators of performance threshold violations.
Regularly maintain the database to preserve performance over time. The PostgreSQL VACUUM operation reclaims storage occupied by dead tuples. The ANALYZE command updates table statistics for the query planner. Schedule these maintenance operations during low-usage periods to minimize impact.
# Manual maintenance
sudo -u postgres vacuumdb --analyze --all