Infrastructure Planning and Architecture
DigitalOcean Resource Allocation
Your Odoo 18 deployment requires careful resource planning from the start. Choose a DigitalOcean droplet with sufficient CPU and memory for your expected user load. For development environments, the Basic droplet with 2GB RAM and 1 vCPU handles light testing. Production deployments demand Premium or CPU-Optimized droplets starting at 4GB RAM for teams under 10 users. Scale to 8GB RAM or higher for larger teams or heavy module usage.
The droplet location impacts performance for your primary user base. Select a region that minimizes latency for your team and customers. DigitalOcean offers global data centers across North America, Europe, and Asia Pacific. Consider data sovereignty requirements when choosing your deployment region. European companies may prefer Frankfurt or London to comply with GDPR data residency needs.
Plan your storage strategy around performance and backup requirements. DigitalOcean’s block storage provides scalable capacity separate from your droplet’s local SSD. Attach a 50GB volume for Odoo filestore and database backups. This separation lets you resize storage without rebuilding the entire server. Implement regular snapshot schedules for disaster recovery.
Network Security Design
Design your network security with a zero-trust approach from the beginning. DigitalOcean Cloud Firewalls provide your first defense layer. Configure rules that permit only essential traffic—SSH access from your IP range, HTTP/HTTPS from anywhere, and custom ports for database connections if needed. Block all other inbound traffic by default.
Segment your services across multiple droplets for production environments. Run PostgreSQL on a separate droplet from your Odoo application server. This isolation limits attack surface and contains potential breaches. Use private networking for database connections between droplets. DigitalOcean’s private network offers free data transfer between resources in the same data center.
Implement a bastion host architecture for administrative access. Never expose your database or application servers directly to the public internet. Configure a dedicated jump host with strict IP whitelisting for SSH access. This approach centralizes your security monitoring and reduces the attack vectors against your core infrastructure.
High Availability Considerations
Plan for redundancy early, even if you deploy a single server initially. DigitalOcean Load Balancers distribute traffic across multiple application servers. Configure health checks that monitor Odoo’s web interface and API endpoints. The load balancer automatically routes traffic away from unhealthy instances.
Design your database architecture for failover protection. DigitalOcean Managed Databases offer automated backups and high availability configurations. The platform handles replication and failover without manual intervention. This service costs more than self-managed PostgreSQL but reduces operational overhead significantly.
Implement a comprehensive backup strategy across all infrastructure layers. DigitalOcean snapshots capture your entire droplet state at regular intervals. Combine this with Odoo’s built-in database backup functionality for point-in-time recovery. Test your restoration process quarterly to verify backup integrity.
Initial Server Configuration
Ubuntu 22.04 LTS Setup
Begin with a clean Ubuntu 22.04 LTS droplet on DigitalOcean. The LTS version guarantees long-term support and security updates. Choose the minimal installation image to reduce attack surface. DigitalOcean’s one-click Ubuntu setup automates the initial provisioning process. Wait for the droplet creation to complete before proceeding.
Update the system packages immediately after deployment. Run apt update && apt upgrade -y to patch known vulnerabilities. Reboot the server if the kernel receives an update. Configure automatic security updates with unattended-upgrades to maintain ongoing protection. Edit /etc/apt/apt.conf.d/50unattended-upgrades to enable critical security patches.
Create a dedicated user account for Odoo operations. Avoid using the root account for daily tasks. Run adduser odoo to create a new system user. Add this user to the sudo group with usermod -aG sudo odoo. Switch to the odoo user account for subsequent configuration steps. This practice limits potential damage from accidental mistakes.
SSH Security Hardening
Secure your SSH access before installing any applications. Change the default SSH port from 22 to a custom value between 1024 and 65535. Edit /etc/ssh/sshd_config and set Port 2222 or another non-standard port. This simple change reduces automated brute force attacks by 90%.
Disable password authentication in favor of SSH key pairs. Generate an RSA key pair on your local machine with ssh-keygen -t rsa -b 4096. Copy the public key to the server using ssh-copy-id -p 2222 odoo@your-server-ip. Test key-based login works before proceeding. Then set PasswordAuthentication no in the SSH configuration.
Configure additional SSH security settings for production environments. Set PermitRootLogin no to prevent direct root access. Use AllowUsers odoo to restrict SSH access to specific accounts. Implement fail2ban to block IP addresses after repeated failed login attempts. These measures create multiple defense layers around your primary access method.
System Optimization and Monitoring
Tune the Linux kernel parameters for web application performance. Increase file descriptor limits for Odoo’s concurrent connections. Edit /etc/security/limits.conf and add odoo soft nofile 65536 and odoo hard nofile 65536. This change allows Odoo to handle thousands of simultaneous users without file descriptor exhaustion.
Configure swap space for memory-constrained environments. Even with sufficient RAM, swap provides a safety net during memory spikes. Use fallocate -l 2G /swapfile to create a 2GB swap file. Set appropriate permissions with chmod 600 /swapfile and activate with mkswap /swapfile && swapon /swapfile. Add the swap file to /etc/fstab for persistence after reboot.
Install essential monitoring tools for system visibility. Use htop for real-time process monitoring and nethogs for network traffic analysis. Configure the DigitalOcean Metrics agent to track droplet performance through their control panel. Set up alert policies for high CPU usage, low memory, or full disk space. Proactive monitoring prevents small issues from becoming major outages.
PostgreSQL Database Installation
PostgreSQL 15 Deployment
Install PostgreSQL 15 from the official repository for optimal performance and security. Ubuntu’s default repositories may contain older versions. Add the PostgreSQL repository with sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'. Import the repository signing key and update your package list.
Install PostgreSQL 15 and essential contrib packages. Run sudo apt install postgresql-15 postgresql-contrib-15 to get the complete database environment. The contrib package adds valuable extensions like pg_trgm for text search optimization. PostgreSQL starts automatically after installation. Verify the service status with systemctl status postgresql.
Secure the PostgreSQL installation with configuration changes. Edit /etc/postgresql/15/main/postgresql.conf and modify the connection settings. Set listen_addresses = 'localhost' to restrict database access to local connections. Change the default port to a non-standard value for additional security. These measures prevent external attacks on your database service.
Database Configuration for Odoo
Create a dedicated PostgreSQL user and database for Odoo. Switch to the postgres system account with sudo -u postgres psql. Execute CREATE USER odoo WITH CREATEDB PASSWORD 'your-secure-password'; to create the database role. Then run CREATE DATABASE odoo WITH OWNER odoo ENCODING 'UTF-8'; to establish the main database. Use a strong, unique password for production environments.
Optimize PostgreSQL performance for Odoo’s workload. Edit /etc/postgresql/15/main/postgresql.conf and adjust key parameters. Set shared_buffers to 25% of your available RAM. Configure effective_cache_size to 50% of total memory. Adjust work_mem based on your concurrent user expectations. These settings ensure PostgreSQL handles Odoo’s complex queries efficiently.
Configure PostgreSQL connection pooling with pgBouncer for high-traffic deployments. Install pgBouncer with apt install pgbouncer. Edit /etc/pgbouncer/pgbouncer.ini to set up the connection pool. This middleware manages database connections more efficiently than Odoo’s built-in pooling. It reduces connection overhead and improves response times during peak usage.
Database Security and Backups
Implement comprehensive database security measures. Configure PostgreSQL to use encrypted connections with SSL certificates. Modify postgresql.conf to enable ssl = on and provide certificate paths. Set up client certificate authentication for additional security layers. These steps protect sensitive business data in transit between Odoo and PostgreSQL.
Create automated database backup routines. Use PostgreSQL’s built-in pg_dump for logical backups. Schedule daily backups with cron: 0 2 * * * pg_dump -U odoo odoo > /backups/odoo-$(date +\%Y\%m\%d).sql. Implement backup rotation to manage storage usage. Test restoration procedures monthly to verify backup integrity.
Monitor database performance and health. Install and configure pgBadger for PostgreSQL log analysis. Set up alerting for slow queries, connection spikes, or replication lag. Use PostgreSQL’s built-in statistics collector to identify performance bottlenecks. Proactive monitoring prevents database issues from affecting your Odoo application.
Odoo 18 Application Deployment
Python Environment Setup
Install Python 3.10 or later for Odoo 18 compatibility. Ubuntu 22.04 includes Python 3.10 in its default repositories. Run sudo apt install python3-pip python3-dev python3-venv to install the complete Python development environment. These packages provide the foundation for Odoo’s Python dependencies.
Create a dedicated Python virtual environment for Odoo. Use python3 -m venv /opt/odoo/venv to establish an isolated environment. Activate the virtual environment with source /opt/odoo/venv/bin/activate. This isolation prevents conflicts between Odoo’s dependencies and system Python packages. The approach simplifies dependency management and future upgrades.
Install Odoo’s Python dependencies using pip. The requirements vary based on your installed modules. Core dependencies include psycopg2-binary for PostgreSQL connectivity, pillow for image processing, and lxml for XML handling. Use pip install -r requirements.txt when available, or install packages individually based on Odoo’s documentation.
Odoo Source Code Installation
Download Odoo 18 source code from the official repository. Use Git for version-controlled deployment: git clone https://github.com/odoo/odoo.git --branch 18.0 --depth 1 /opt/odoo/odoo-server. The branch flag ensures you get the stable 18.0 release. The depth parameter limits history download for faster deployment.
Configure Odoo’s deployment directory structure. Create separate directories for custom addons, logs, and session data: mkdir -p /opt/odoo/{addons,sessions,logs}. Set appropriate ownership with chown -R odoo:odoo /opt/odoo. This organization keeps your Odoo installation clean and manageable.
Install Odoo’s system dependencies for full functionality. Run sudo apt install build-essential libxslt-dev libldap2-dev libsasl2-dev libssl-dev to compile Python packages with native extensions. These libraries support Odoo’s advanced features like LDAP integration and report generation. Missing dependencies cause runtime errors and performance issues.
Odoo Configuration File
Create Odoo’s configuration file at /etc/odoo.conf with appropriate permissions. Set ownership with chown odoo:odoo /etc/odoo.conf and permissions with chmod 640. The configuration file controls all aspects of Odoo’s behavior. Use a minimal configuration that specifies essential parameters.
Configure database connection settings in odoo.conf. Set db_host = localhost and db_port = 5432 to connect to your PostgreSQL instance. Specify db_user = odoo and db_password = your-secure-password for authentication. These parameters establish the database linkage that Odoo requires at startup.
Define file paths and operational parameters. Set addons_path = /opt/odoo/odoo-server/addons,/opt/odoo/addons to include both core and custom modules. Configure data_dir = /opt/odoo/sessions for session storage. Specify logfile = /opt/odoo/logs/odoo.log for centralized logging. These paths organize Odoo’s runtime data effectively.
Systemd Service Configuration
Create a systemd service file for Odoo at /etc/systemd/system/odoo.service. This approach manages Odoo as a system service with automatic startup and proper process supervision. The service file defines execution parameters, user context, and restart behavior.
Configure the service definition with security best practices. Set User=odoo and Group=odoo to run the process with minimal privileges. Specify ExecStart=/opt/odoo/venv/bin/python3 /opt/odoo/odoo-server/odoo-bin -c /etc/odoo.conf to launch Odoo with your configuration. These settings ensure Odoo runs in its dedicated environment.
Enable the Odoo service to start automatically after system reboot. Run systemctl enable odoo to register the service. Start Odoo with systemctl start odoo and verify its status with systemctl status odoo. Monitor the logs with journalctl -u odoo -f to identify any startup issues. Proper service management ensures Odoo remains available through system maintenance.
Nginx Reverse Proxy Configuration
Nginx Installation and Setup
Install Nginx from Ubuntu’s official repositories. Run sudo apt install nginx to get the latest stable version. The package includes both the web server and essential management tools. Nginx handles SSL termination, static file serving, and load balancing for your Odoo deployment.
Configure Nginx as a reverse proxy for Odoo. Create a new configuration file at /etc/nginx/sites-available/odoo. This approach keeps your Odoo configuration separate from default Nginx settings. Create a symbolic link to the sites-enabled directory to activate the configuration.
Set up the basic reverse proxy configuration. Define an upstream block that points to your Odoo instance: upstream odoo { server 127.0.0.1:8069; }. This configuration routes incoming HTTP requests to Odoo’s built-in web server. The approach improves security by not exposing Odoo directly to the internet.
SSL Certificate Implementation
Obtain an SSL certificate from Let’s Encrypt using Certbot. Install Certbot with sudo apt install certbot python3-certbot-nginx. Run sudo certbot --nginx -d your-domain.com to request and install a certificate automatically. Certbot handles domain validation and configures Nginx for HTTPS redirection.
Configure strong SSL security settings in Nginx. Implement modern encryption protocols and disable outdated ciphers. Set ssl_protocols TLSv1.2 TLSv1.3; to restrict protocol options. Specify strong cipher suites that balance security and compatibility. These settings protect sensitive business data during transmission.
Implement HTTP to HTTPS redirect for all traffic. Create a separate server block that listens on port 80. Configure this block to return a 301 redirect to the HTTPS version of your site. This practice ensures users always connect through encrypted channels, even if they type HTTP URLs.
Performance Optimization
Configure Nginx for optimal static file handling. Odoo serves many static assets like CSS, JavaScript, and images. Set up location blocks that serve these files directly from Nginx. This approach reduces load on the Odoo application server and improves response times.
Implement gzip compression for text-based content. Enable gzip on; in your Nginx configuration. Configure compression levels for different file types: HTML, CSS, JavaScript, and JSON. Compression reduces bandwidth usage and speeds up page loads for remote users.
Set appropriate cache control headers for static resources. Configure expires directives for images, CSS, and JavaScript files. Browser caching reduces repeat requests for unchanged assets. This optimization significantly improves perceived performance for returning users.
Security Hardening and Firewall
UFW Firewall Configuration
Configure Uncomplicated Firewall (UFW) as your primary defense layer. Enable UFW with sudo ufw enable after setting up your initial rules. The firewall blocks all incoming traffic by default, requiring explicit permission for allowed services.
Set up firewall rules for essential services. Allow SSH access on your custom port with sudo ufw allow 2222/tcp. Permit HTTP and HTTPS traffic with sudo ufw allow 80/tcp and sudo ufw allow 443/tcp. These rules maintain accessibility while blocking unnecessary ports.
Implement strict outbound filtering for enhanced security. Configure UFW to restrict outgoing connections to essential services only. Allow DNS resolution, package updates, and outbound email if needed. This approach prevents data exfiltration even if an attacker compromises your system.
Application Security Measures
Implement fail2ban for automated intrusion prevention. Install with sudo apt install fail2ban and configure Odoo-specific jails. Create a filter for Odoo login attempts and set appropriate ban times. Fail2ban monitors logs and blocks IP addresses with suspicious behavior.
Harden file permissions across your Odoo installation. Set strict ownership and access rights for configuration files, especially those containing database passwords. Use chmod 600 for sensitive files and chmod 644 for public resources. Proper permissions limit damage from application-level vulnerabilities.
Configure Odoo’s built-in security features for production use. Set list_db = False in odoo.conf to prevent database listing. Implement strong password policies for user accounts. Enable two-factor authentication for administrative users. These measures protect against common web application attacks.
System Monitoring and Auditing
Install and configure auditd for system call monitoring. The audit framework tracks file access, network activity, and user commands. Set up rules that monitor sensitive directories like /etc/odoo and /opt/odoo. Regular audit review helps detect unauthorized access attempts.
Implement file integrity monitoring with AIDE. Initialize the database with sudo aideinit and schedule regular checks with cron. AIDE alerts you to unauthorized file changes that might indicate a security breach. This monitoring complements your backup strategy for complete system protection.
Set up centralized logging for security analysis. Configure rsyslog to forward system logs to a secure remote server. Implement log rotation to manage disk space usage. Regular log review helps identify security incidents and operational issues before they escalate.
Performance Optimization and Caching
Redis Caching Implementation
Install Redis server for Odoo session storage and caching. Use sudo apt install redis-server to get the latest version. Redis handles Odoo’s session data more efficiently than file-based storage. The in-memory database reduces load on your PostgreSQL instance.
Configure Redis for optimal memory usage and persistence. Edit /etc/redis/redis.conf to set appropriate memory limits. Enable RDB snapshots for data persistence in case of server restart. These settings balance performance with data safety for your caching layer.
Integrate Redis with Odoo for session storage and caching. Modify odoo.conf to include http_session_redis = True and set the Redis server connection parameters. This integration moves session management from the file system to memory, improving response times for authenticated users.
Odoo Performance Tuning
Configure Odoo’s worker processes for your hardware resources. Set workers = 4 in odoo.conf for a server with 4 CPU cores. Adjust this value based on your available processors and memory. Worker processes handle concurrent requests more efficiently than the default single-process mode.
Optimize Odoo’s memory and timeout settings for stability. Set limit_memory_hard = 2684354560 and limit_memory_soft = 2147483648 to prevent worker memory leaks. Configure limit_time_cpu and limit_time_real to terminate long-running operations. These parameters protect your system from resource exhaustion.
Enable Odoo’s built-in caching for frequently accessed data. Configure the --cache-spec parameter or use Redis for distributed caching. Caching reduces database queries for static or semi-static data like translations, company information, and user preferences.
Database Optimization Techniques
Implement PostgreSQL query optimization for Odoo’s specific workload. Create indexes on frequently searched fields like partner names, product codes, and invoice numbers. Use EXPLAIN ANALYZE to identify slow queries and optimize them. Regular database maintenance ensures consistent performance.
Schedule regular database maintenance tasks. Run VACUUM ANALYZE during low-traffic periods to update table statistics. Implement automatic index rebuilding for heavily updated tables. These maintenance activities prevent database bloat and maintain query performance over time.
Monitor system resources to identify performance bottlenecks. Use tools like htop, nethogs, and iotop to track CPU, memory, network, and disk usage. Set up alerts for resource thresholds that might impact Odoo’s responsiveness. Proactive monitoring prevents performance degradation before users notice issues.