System Preparation and Dependency Installation

Ubuntu 22.04 Baseline Configuration

Begin with a comprehensive system update to ensure all existing packages reach their latest stable versions. Execute sudo apt update && sudo apt upgrade -y to refresh your package repositories and apply security patches. This foundational step prevents conflicts between Odoo dependencies and system libraries. Reboot your server if the kernel receives an update during this process.

Create a dedicated system user account for Odoo operations using sudo adduser --system --group --home /opt/odoo odoo. This security measure isolates Odoo processes from privileged accounts. The designated home directory provides a consistent location for application files and custom modules. User isolation limits potential damage from security vulnerabilities.

Install essential Python development tools with sudo apt install -y python3-pip python3-dev. These packages provide the compilation infrastructure for Python wheels and native extensions. Odoo 18 requires Python 3.8+ which Ubuntu 22.04 includes in its default repositories. The development headers enable compilation of performance-critical Python packages.

Database Server Installation

PostgreSQL serves as the primary database backend for Odoo operations. Install the database server using sudo apt install -y postgresql postgresql-contrib. The contrib package adds valuable administrative extensions for database management. This installation creates a postgres system user that owns the database cluster and processes.

Switch to the postgres user account with sudo su - postgres. Create a dedicated database user for Odoo using createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo. This command restricts the database user to appropriate privilege levels for security. Record the password you assign for later configuration steps.

Return to your normal user account and verify the database user creation with sudo -u postgres psql -c "SELECT usename FROM pg_user WHERE usename='odoo'". This confirmation ensures your database layer maintains proper user segregation. The Odoo database user should possess permissions for database creation and basic operations only.

System Package Dependencies

Odoo requires numerous system libraries for PDF generation, XML processing, and other enterprise functions. Install these dependencies using sudo apt install -y build-essential libssl-dev libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libjpeg-dev libpq-dev libffi-dev fontconfig. These packages provide native code support for Python modules that Odoo utilizes.

Node.js and Less CSS compiler support the Odoo web interface features. Install the Node.js runtime from the standard repositories with sudo apt install -y nodejs npm. This installation provides the necessary JavaScript execution environment for frontend asset processing. Link the nodejs binary to the expected node name using sudo ln -s /usr/bin/nodejs /usr/bin/node.

Install the Less CSS compiler globally using sudo npm install -g less. This tool transforms Less stylesheets into standard CSS that browsers render. The Odoo framework employs Less for its modular styling system and theme development. Verify the installation completes without permission errors or dependency warnings.

Odoo 18 Application Deployment

Python Environment Configuration

Create a dedicated Python virtual environment for Odoo isolation. Install the virtualenv package using sudo pip3 install virtualenv. This tool creates self-contained Python environments that prevent package conflicts. Navigate to the Odoo user home directory with sudo mkdir /opt/odoo/odoo-server and adjust ownership using sudo chown odoo:odoo /opt/odoo/odoo-server.

Switch to the Odoo user account with sudo su - odoo. Create the virtual environment inside the user home directory using virtualenv /opt/odoo/odoo-server/venv. This command builds a complete Python runtime isolation layer. Activate the virtual environment with source /opt/odoo/odoo-server/venv/bin/activate before proceeding with Odoo installation.

Install Wheel package support using pip install wheel. This precompilation format accelerates package installation and reduces build dependencies. The Wheel infrastructure ensures reliable deployment of binary Python extensions without compilation tools on production systems. Verify the virtual environment operates independently from the system Python.

Odoo Source Code Installation

Download the Odoo 18 source code using Git version control. Install Git with sudo apt install -y git if not present. Clone the Odoo repository using git clone https://github.com/odoo/odoo.git /opt/odoo/odoo-server/odoo --branch 18.0 --depth 1. The depth parameter limits history retrieval to conserve bandwidth and storage space.

Install Python dependencies from the Odoo requirements file using pip install -r /opt/odoo/odoo-server/odoo/requirements.txt. This command processes all necessary Python packages for Odoo operation. The installation may take several minutes as it compiles native extensions. Monitor for any compilation errors that indicate missing system dependencies.

Create a custom addons directory for third-party modules using mkdir /opt/odoo/odoo-server/custom-addons. This separation maintains clear boundaries between core Odoo code and extensions. Set proper ownership with sudo chown -R odoo:odoo /opt/odoo/odoo-server. The directory structure now supports modular application development.

Odoo Configuration File Setup

Create the Odoo configuration file at /etc/odoo.conf using sudo touch /etc/odoo.conf and sudo chown odoo:odoo /etc/odoo.conf. This central configuration file controls all aspects of Odoo operation. Apply strict permissions with sudo chmod 640 /etc/odoo.conf to prevent unauthorized access to database credentials.

Populate the configuration file with essential parameters. The [options] section should contain admin_passwd = your_secure_master_password for database management security. Set db_host = localhost and db_user = odoo with the corresponding database password. Specify addons_path = /opt/odoo/odoo-server/odoo/addons,/opt/odoo/odoo-server/custom-addons to define module search paths.

Configure operational parameters for production use. Set logfile = /var/log/odoo/odoo-server.log to centralize logging output. Define log_level = warn to balance detail and performance. Specify proxy_mode = True when operating behind a reverse proxy. These settings establish a foundation for production monitoring and troubleshooting.

Service Configuration and Process Management

Systemd Service Integration

Create a systemd service file to manage Odoo as a system service. Place the file at /etc/systemd/system/odoo.service with sudo touch /etc/systemd/system/odoo.service. This service definition enables proper process supervision and automatic startup. Systemd provides robust process management capabilities beyond simple init scripts.

Define the service configuration with precise execution parameters. The [Unit] section should contain Description=Odoo 18 ERP System and After=postgresql.service to establish service dependencies. The [Service] section must specify Type=simple with User=odoo and Group=odoo for security context. Set ExecStart=/opt/odoo/odoo-server/venv/bin/python3 /opt/odoo/odoo-server/odoo/odoo-bin -c /etc/odoo.conf for the execution command.

Configure process management and resource limits for stability. Set Restart=on-failure and RestartSec=5 to handle temporary issues automatically. Define TimeoutStartSec=300 to accommodate initial database operations. Specify KillMode=mixed for graceful shutdown procedures. These parameters ensure the service recovers from common runtime problems.

Enable the Odoo service to start automatically with sudo systemctl enable odoo. This command links the service definition into the system startup sequence. Start the service immediately with sudo systemctl start odoo and verify its status using sudo systemctl status odoo. The output should show an active (running) state without error messages.

Logging Infrastructure Setup

Create a dedicated log directory with proper permissions using sudo mkdir /var/log/odoo and sudo chown odoo:odoo /var/log/odoo. This centralized location stores all Odoo application logs for troubleshooting and auditing. The directory separation maintains clean organization of system versus application logging.

Configure log rotation to prevent disk space exhaustion. Create a logrotate configuration file at /etc/logrotate.d/odoo with appropriate rotation policies. Set weekly rotation with rotate 8 to maintain two months of historical logs. Specify create 640 odoo odoo to preserve file ownership after rotation. The compression directive reduces storage requirements for older log files.

Monitor log output during initial startup using sudo journalctl -u odoo -f. This command displays real-time service messages from systemd. Look for database connection success messages and HTTP service initialization. Address any error messages related to permissions or missing dependencies before proceeding to the next configuration phase.

Process Optimization Parameters

Adjust Odoo configuration for optimal performance based on your hardware resources. Set workers = 2 for systems with 2-4 CPU cores, scaling appropriately for larger systems. Define limit_memory_hard = 2684354560 and limit_memory_soft = 2147483648 to establish memory boundaries for worker processes. These limits prevent memory exhaustion from module defects.

Configure database connection pooling with db_maxconn = 64 to manage concurrent database operations. Set list_db = False in production environments to enhance security through information disclosure prevention. Define max_cron_threads = 2 to limit background task processing resources. These parameters fine-tune resource allocation for production workloads.

Nginx Reverse Proxy Configuration

SSL Termination Setup

Install Nginx web server using sudo apt install -y nginx. This high-performance web server handles SSL termination and static file serving. Obtain an SSL certificate from Let’s Encrypt using Certbot with sudo apt install -y certbot python3-certbot-nginx. Execute sudo certbot --nginx -d your-domain.com to request and install a trusted certificate.

Configure Nginx as a reverse proxy for Odoo application traffic. Create a server block configuration at /etc/nginx/sites-available/odoo with proper upstream directives. The configuration should proxy requests to http://127.0.0.1:8069 where Odoo listens by default. Enable the site configuration using sudo ln -s /etc/nginx/sites-available/odoo /etc/nginx/sites-enabled/.

Implement security headers and performance optimizations in the Nginx configuration. Set proxy_set_header X-Forwarded-Host $host and proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for to preserve original client information. Define proxy_read_timeout 720s and proxy_connect_timeout 720s to accommodate long-running operations. These settings maintain application functionality through the proxy layer.

Static Content Optimization

Configure Nginx to serve static files directly for improved performance. Create location blocks that match Odoo static paths including /web/static/ and /web/image/. Set aggressive caching headers for static resources with expires 1y and add_header Cache-Control "public, immutable". This approach reduces application server load and accelerates page loading.

Enable Gzip compression for text-based content types. Configure gzip_types to include JavaScript, CSS, HTML, and XML responses. Set gzip_comp_level 6 to balance compression ratio with CPU overhead. The compression reduces bandwidth consumption and improves transfer times for clients with limited connectivity.

Verify the Nginx configuration syntax with sudo nginx -t. This validation check identifies syntax errors before applying changes. Reload the Nginx service with sudo systemctl reload nginx to activate the new configuration. Test the proxy functionality by accessing your domain with HTTPS and verifying Odoo loads without mixed content warnings.

Database Optimization and Maintenance

PostgreSQL Performance Tuning

Adjust PostgreSQL configuration for Odoo workload characteristics. Locate the main configuration file at /etc/postgresql/14/main/postgresql.conf. Modify memory settings based on your available system resources. Set shared_buffers = 25% of available RAM and effective_cache_size = 50% of total RAM. These parameters optimize database memory utilization.

Configure checkpoint and WAL settings for better write performance. Set checkpoint_completion_target = 0.9 to spread write operations more evenly. Adjust wal_buffers = 16MB to accommodate transaction volume. Define random_page_cost = 1.1 for SSD storage systems. These tuning parameters accelerate common database operations in Odoo.

Restart PostgreSQL to apply configuration changes with sudo systemctl restart postgresql. Monitor database performance using PostgreSQL statistics views like pg_stat_database and pg_stat_user_tables. Identify slow queries using pg_stat_statements extension for targeted optimization efforts.

Automated Backup Procedures

Implement a comprehensive backup strategy for Odoo filestore and database. Create a backup directory with sudo mkdir /opt/odoo/backups and sudo chown odoo:odoo /opt/odoo/backups. Develop a shell script that executes pg_dump for database backup and rsync for filestore duplication. Include rotation logic to manage backup storage consumption.

Schedule automated backups using cron jobs. Access the crontab for the Odoo user with sudo crontab -u odoo -e. Add entries for daily database dumps and weekly full backups. Configure log rotation for backup operations to monitor success and failure patterns. Test restoration procedures regularly to validate backup integrity.

Monitor backup completion and storage capacity. Implement alerting for backup failures through log monitoring or script exit code checking. Track backup storage growth to anticipate capacity requirements. Document restoration procedures for disaster recovery scenarios to minimize downtime during critical incidents.

Security Hardening and Access Control

Network Security Configuration

Configure firewall rules to restrict unnecessary network exposure. Ubuntu 22.04 includes UFW (Uncomplicated Firewall) for simplified management. Enable SSH access with sudo ufw allow OpenSSH and HTTP/HTTPS with sudo ufw allow 'Nginx Full'. Activate the firewall with sudo ufw enable to enforce these rules.

Restrict database network access to localhost only. Verify PostgreSQL configuration at /etc/postgresql/14/main/pg_hba.conf contains host all all 127.0.0.1/32 md5 for IPv4 connections. Set listen_addresses = 'localhost' in the main PostgreSQL configuration file. These measures prevent external database connection attempts.

Implement fail2ban protection against brute force attacks. Install with sudo apt install -y fail2ban and create a Odoo-specific jail configuration. Monitor Odoo authentication logs for repeated failed login attempts. Configure appropriate ban durations and whitelist trusted IP addresses to maintain accessibility.

Application Security Measures

Enforce strong password policies for Odoo user accounts. Configure password complexity requirements through Odoo settings with minimum length and character variety. Enable two-factor authentication for administrative accounts to add an additional security layer. Regular password rotation policies reduce the impact of credential compromise.

Implement appropriate access controls for Odoo database operations. Create separate database users for different security contexts when integrating with external systems. Apply principle of least privilege to all database account permissions. Regular access reviews identify unnecessary privileges that require revocation.

Secure the Odoo configuration file with strict permissions. Verify that /etc/odoo.conf has 640 permissions with odoo:odoo ownership. The master admin password in the configuration file should use strong, unique values different from other system credentials. Regular security audits identify configuration drift from established baselines.

System Monitoring and Alerting

Implement comprehensive logging for security event detection. Configure Odoo to log authentication attempts and administrative actions. Centralize logs using syslog or dedicated log management solutions. Regular log analysis identifies suspicious patterns that indicate security incidents.

Set up system monitoring for resource utilization and service availability. Monitor disk space, memory usage, and CPU load to detect performance anomalies. Configure alerting for service downtime through health checks against the Odoo web interface. Proactive monitoring prevents minor issues from escalating into major incidents.

Establish regular security patch management procedures. Subscribe to security announcements for Ubuntu, PostgreSQL, and Odoo. Test patches in a staging environment before production deployment. Maintain a documented rollback procedure for problematic updates to minimize business disruption.

Performance Monitoring and Optimization

Resource Utilization Analysis

Monitor Odoo worker process resource consumption using system tools. Implement htop for real-time process monitoring and iotop for disk I/O analysis. Track memory usage patterns to identify potential leaks in custom modules. Establish baseline performance metrics during normal operation for comparison during issues.

Analyze database performance through PostgreSQL statistics. Monitor query execution times using pg_stat_statements extension. Identify frequently executed queries that benefit from optimization. Track index usage statistics to locate missing indexes that degrade performance.

Implement application performance monitoring (APM) tools for detailed code-level insights. Tools like py-spy provide Python profiling without code instrumentation. Monitor HTTP request response times to identify slow database queries or complex business logic. Performance data guides optimization efforts toward maximum impact.

Caching Strategy Implementation

Configure Redis for Odoo caching and session storage. Install Redis server using sudo apt install -y redis-server. Configure Odoo to use Redis for cache with cache_redis = True in the configuration file. Set appropriate expiration times for different data types to balance freshness and performance.

Implement browser-side caching policies through Nginx configuration. Set aggressive caching headers for static assets that rarely change. Configure conditional requests using ETags for dynamic content that updates frequently. The caching hierarchy reduces server load and improves user experience.

Utilize Odoo’s built-in caching mechanisms for frequently accessed data. Configure osv_memory_count_limit to control in-memory record caching. Monitor cache hit ratios to assess effectiveness of caching strategies. Adjust cache sizes based on available system memory and workload patterns.

Database Maintenance Procedures

Schedule regular PostgreSQL maintenance operations during low-usage periods. Perform VACUUM ANALYZE operations to update table statistics and reclaim storage. Monitor table bloat using pgstattuple extension to identify tables that benefit from aggressive vacuuming. Regular maintenance preserves query performance over time.

Implement connection pooling to reduce database connection overhead. Use PgBouncer or PostgreSQL’s built-in connection pooler to manage database connections. Configure appropriate pool sizes based on concurrent user count and worker processes. Connection pooling improves resource utilization and application responsiveness.

Monitor long-running queries and database locks that impact performance. Configure PostgreSQL log_min_duration_statement to identify slow queries automatically. Set up alerts for long-held locks that block other database operations. Proactive identification of performance issues prevents user experience degradation.