In a nutshell, here's what you need to do to deploy Odoo on your server:

  • Clone/copy the Odoo On-Premise Setup Package repository to your server
  • Make a local copy of the .env.template file and insert your setup parameters
  • Make the startup script executable and execute it
  • Change the password of the admin user in your Odoo production environment

Detailed configuration steps are described below.

Server preparation​​

Here are a few steps that may be necessary when setting up a server. Some of these you may have already done.

  • You need a server where you have root access and it is running Linux. Tested and supported versions are Ubuntu 18.04, 20.04, or 22.04.
  • You have to set up a DNS A record to map your server's IP address to your domain (usually done on the site where you bought the domain name).
  • Generate an SSH key for your server, for example, using ssh-keygen -t rsa
  • Copy the generated key and add it to your GitHub. To access the key, use cat ~/.ssh/id_rsa.pub
    For more info, see: Adding a new SSH key to your GitHub account

Setting up Odoo

1. Clone or copy the Odoo On-Premise Setup Package repository to your server and navigate to it

git clone git@github.com:winotto-ou/odoo_setup.git YOUR_PROJECT_NAME

2. Make a copy of the .env.template file and name it .env

cp .env.template .env

3. Edit parameters in .env file (see section .env file parameters below)

nano .env​

4. Add execute rights to the starting script

sudo chmod +x starting_script.sh​

5. Run the starting script

bash starting_script.sh​

6. Change production environment admin user password

By default, the admin login will be username admin and password admin. You have to change it immediately!

To change the default password:

  • Navigate to your production environment and log in.
  • Once logged in, navigate to the user settings. Usually, this can be found by clicking on your username or avatar in the top right corner of the screen.
  • Select My Profile from the dropdown.
  • Navigate to the Account Security tab on the user profile form and press the Change Password button.

.env file parameters​​​

Here is a short explanation of the .env file of the Odoo On-Premise Setup Package.

Parameters marked with an asterisk (*) must be changed. For all other parameters, it is perfectly fine to use the default values.

# Localhost Testing
LOCALHOST_TESTING: Use this to test this setup in localhost.
This will bypass real cert generation and add your testing URLs to your OS host file.
Also, cron jobs are not created. DO NOT use real URLs.
For example, add localhost at the beginning (localhost.my.url.com).
Navigating the site will give a security warning in most browsers.

# Main Variables
POSTGRES_VERSIONSpecifies the PostgreSQL version. It should be 12.0 or above.
EMAILEmail address is required for certificate generation.
HTTP_BODY_SIZEMaximum allowed size of the client request body, used by nginx.

# Production Environment Variables
PRODUCTION_URLURL for the production instance of Odoo.
ADMIN_PASSWD: Master password, needed for accessing database management screens.
DB_PASSWORD: Password for the Odoo database.
DB_NAMEName of the Odoo database.
This database will be automatically created during setup.
Choose carefully. It can't be changed later.
WORKERS: Number of worker processes for Odoo.
Rule of thumb for maximum workers: (#CPU * 2) + 1 - cron_workers. So for server with 4CPU and one cron worker (4*2) + 1 - 1 = 8.
Rule of thumb for needed workers: 1 worker ~= 6 concurrent odoo users
LIMIT_MEMORY_SOFTMaximum allowed virtual memory per worker (in bytes).
When reached, the worker will be reset after the current request.
Default is 2048 MiB (2048 * 1024 * 1024).
LIMIT_MEMORY_HARDMaximum allowed virtual memory per worker (in bytes).
When reached, any memory allocation will fail (default 2560 MiB = 2560 * 1024 * 1024).
LIMIT_TIME_CPUMaximum allowed CPU time per request in seconds (default 60).
LIMIT_TIME_REALMaximum allowed real-time per request in seconds (default 120).

# Test Environment Variables
All the same variables as in production, except DB_NAME is replaced with two other variables
allowing database management and multiple databases.
Required changes to parameters are the same as in the production section.

TEST_DBFILTERDatabase filter pattern.
TEST_LIST_DBFlag to enable listing databases in the test environment
when navigating to https://YourOdooUrl/web/database/manager.

# Backups
BACKUP_DIRDirectory where backups will be stored.
BACKUP_KEEP_DAYSNumber of days to keep backups.
BACKUP_CRON_SCHEDULE: Cron schedule for automated backups.

Folder structure​​​​

Odoo On-Premise Setup Package consists of the following files and folders:

​​ production
- Folder for custom modules for production. 
 my_custom_modules - This could be, for example, a Git repository
my_module - Folder containing Odoo module files
apt.txt - All apt packages listed here will be automatically installed
requirements.txt - All Python packages listed here
will be automatically installed

 test - Folder for custom modules for testing (same structure as above)
 certbot - Folder holding all information for certificates and renewals
backup_script.sh - Script that handles production environment auto backups.
This is run by cron

 renew_script.sh - Script that handles renewing certificates.
This is run by cron

- folder containing all Let's Encrypt log files
 backup_script.log - Log file for backup job
 renew_script.log - Log file for script renewing job
production.conf.template - Template for generating production environment
Nginx configuration

 test.conf.template - Template for generating test environment nginx conf
odoo-entrypoint.sh - Default entrypoint is overwritten to support Python and
APT package installation when starting Odoo container. It also supports dynamic
configuration file generation for Odoo

 ​su.text - Gives Odoo user the right to use sudo without prompting for a password
inside the Odoo container. This is needed for automatic apt package installation

 template.conf - Template used for generating Odoo configuration files
 .env.template Default file for variables. This is the file that needs to be copied
and named .env. This is the only file that needs user input

 docker-compose.yml - File that holds all information about Docker containers
and orchestrates them. Just use Docker commands for running, stopping,
and restarting containers

 starting_script.sh File that handles initial setup. Not needed after that

Start building your business with Odoo On-Premise

 Sart now—it's fast, cheap and simple