Install Odoo on Ubuntu and Debian

Install Odoo on Ubuntu Debian PostgreSQL Configure Odoo with Nginx reverse proxy

Odoo is a powerful, open-source business application suite that covers a wide range of functionalities, including customer relationship management (CRM), sales, project management, manufacturing, inventory management, accounting, and more. In this article, we’ll guide you through the process of installing Odoo on Ubuntu or Debian-based Linux distributions.

Prerequisites

Before we begin, ensure that you have the following prerequisites in place:

  1. Server or Virtual Machine: You’ll need a server or a virtual machine running Ubuntu 18.04/20.04/22.04 or Debian 12/11/10. For production environments, it’s recommended to use a dedicated server or a virtual private server (VPS). However, for testing or development purposes, you can install Odoo on your local machine.
  2. System Updates: Make sure your system is up-to-date by running the following commands:
$ sudo apt update
$ sudo apt upgrade
  1. Python 3: Odoo requires Python 3.7 or later. You can check your Python version by running:
$ python3 --version

If Python 3 is not installed or the version is outdated, you can install it using the following command:

$ sudo apt install python3 python3-pip
  1. PostgreSQL: Odoo requires a PostgreSQL database server. You can install it with the following command:
$ sudo apt install postgresql

Step 1: Create a New PostgreSQL User and Database

Odoo requires a dedicated PostgreSQL user and database for its operation. Follow these steps to create them:

  1. Switch to the PostgreSQL superuser account:
$ sudo su postgres
  1. Create a new PostgreSQL user for Odoo:
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo

Enter a secure password when prompted.

  1. Create a new PostgreSQL database for Odoo:
createdb --username postgres --owner odoo --encoding UTF8 --template template0 odoo
  1. Exit the PostgreSQL superuser account:
exit

Step 2: Install Odoo from Source

Odoo provides official source code repositories for various versions. In this guide, we’ll install the latest stable version available at the time of writing this article.

  1. Install the required dependencies:
$ sudo apt install git python3-dev libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libpq-dev libjpeg62-turbo-dev libtiff5-dev libxmlsec1 libxmlsec1-dev node-less
  1. Create a new directory for Odoo and navigate to it:
$ mkdir ~/odoo
$ cd ~/odoo
  1. Clone the Odoo repository:
$ git clone https://github.com/odoo/odoo.git --branch 16.0 --depth=1

This will clone the latest version of the Odoo 16.0 branch. If you want to install a different version, replace 16.0 with the desired version number.

  1. Create a new Python virtual environment and activate it:
$ python3 -m venv odoo-venv
$ source odoo-venv/bin/activate
  1. Install Odoo’s Python dependencies:
$ pip install -r odoo/requirements.txt
  1. Install additional Python dependencies required for Odoo:
$ pip install Babel psycopg2 psutil pyldap qrcode reportlab

Step 3: Configure Odoo

Before starting Odoo, you need to configure it to use the PostgreSQL database you created earlier.

  1. Create a new configuration file:
$ mkdir ~/odoo/config
$ nano ~/odoo/config/odoo.conf
  1. Add the following content to the odoo.conf file, replacing YOUR_ODOO_PASSWORD with the password you set for the odoo PostgreSQL user:
[options]
addons_path = /home/YOUR_USERNAME/odoo/odoo/addons
data_dir = /home/YOUR_USERNAME/odoo/.local/share/Odoo
db_host = False
db_port = False
db_user = odoo
db_password = YOUR_ODOO_PASSWORD
db_name = False
logfile = /home/YOUR_USERNAME/odoo/odoo.log

Replace YOUR_USERNAME with your actual username on the system.

  1. Save the file and exit the text editor.

Step 4: Start Odoo

Now that you’ve installed and configured Odoo, you can start the Odoo server.

  1. Navigate to the Odoo directory:
$ cd ~/odoo/odoo
  1. Start the Odoo server:
$ python3 odoo-bin --config=/home/YOUR_USERNAME/odoo/config/odoo.conf

Replace YOUR_USERNAME with your actual username on the system.

Odoo will start, and you should see some initialization logs in your terminal. Once the server is ready, you’ll see a message similar to:

Odoo server is running, waiting for connections...

Step 5: Access the Odoo Web Interface

Odoo provides a web-based user interface that you can access through a web browser.

  1. Open a web browser and navigate to http://localhost:8069 or http://YOUR_SERVER_IP:8069 if you’re accessing Odoo from a remote server.
  2. On the initial setup page, you’ll be prompted to create a master password for the database. Choose a secure password and proceed.
  3. Next, you’ll be asked to create an Odoo database. Provide a name for your database and a password for the administrator account.
  4. After the database creation process is complete, you’ll be redirected to the Odoo login page. Enter the administrator credentials you set during the database creation step.
  5. You should now be able to access the Odoo web interface and start exploring its features.

Advanced Configuration

The steps outlined above provide a basic installation of Odoo. However, there are several additional configurations you may want to consider for production environments or specific use cases.

Running Odoo as a Service

Running Odoo as a system service ensures that it starts automatically after system reboots and provides better process management capabilities.

  1. Create a new system user for Odoo:
$ sudo adduser --system --no-create-home --group odoo
  1. Create a new system unit file for Odoo:
$ sudo nano /etc/systemd/system/odoo.service
  1. Add the following content to the file, replacing YOUR_USERNAME with your actual username on the system:
[Unit]
Description=Odoo Open Source ERP and CRM
Requires=postgresql.service
After=network.target postgresql.service
[Service]
Type=simple
User=odoo
Group=odoo
ExecStart=/home/YOUR_USERNAME/odoo/odoo-venv/bin/python3 /home/YOUR_USERNAME/odoo/odoo/odoo-bin --config=/home/YOUR_USERNAME/odoo/config/odoo.conf
KillMode=mixed
[Install]
WantedBy=multi-user.target
  1. Save the file and exit the text editor.
  2. Reload the systemd daemon:
$ sudo systemctl daemon-reload
  1. Start the Odoo service:
$ sudo systemctl start odoo
  1. Enable the Odoo service to start automatically on system boot:
$ sudo systemctl enable odoo

Configuring Odoo to Use a Reverse Proxy

In production environments, it’s recommended to use a reverse proxy server like Nginx or Apache to handle incoming requests and forward them to the Odoo server. This setup provides better security, performance, and scalability. Here’s an example of how to configure Nginx as a reverse proxy for Odoo:

  1. Install Nginx:
$ sudo apt install nginx
  1. Create a new Nginx configuration file for Odoo:
$ sudo nano /etc/nginx/sites-available/odoo
  1. Add the following content to the file, replacing YOUR_SERVER_IP with your server’s IP address or domain name:
server {
    listen 80;
    server_name YOUR_SERVER_IP;
    proxy_read_timeout 720s;
    proxy_connect_timeout 720s;
    proxy_send_timeout 720s;
    location / {
        proxy_pass http://127.0.0.1:8069;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location /longpolling {
        proxy_pass http://127.0.0.1:8072;
    }
    location ~* /(web/static|web/tests)/ {
        proxy_pass http://127.0.0.1:8069;
        proxy_cache_valid 200 90m;
        proxy_buffering on;
        proxy_redirect off;
    }
}
  1. Save the file and exit the text editor.
  2. Enable the Odoo Nginx configuration:
$ sudo ln -s /etc/nginx/sites-available/odoo /etc/nginx/sites-enabled/
  1. Restart Nginx:
$ sudo systemctl restart nginx
  1. In the Odoo configuration file (~/odoo/config/odoo.conf), add the following lines to enable the longpolling feature:
longpolling_port = 8072
  1. Restart the Odoo service:
$ sudo systemctl restart odoo

With this configuration, Nginx will handle incoming requests and forward them to the Odoo server running on 127.0.0.1:8069. The longpolling feature, used for real-time updates in Odoo, is configured to run on 127.0.0.1:8072.

Enabling SSL/TLS Encryption

To secure your Odoo instance with SSL/TLS encryption, you’ll need to obtain an SSL/TLS certificate and configure Nginx to use it. Here’s an example of how to do this:

  1. Obtain an SSL/TLS certificate from a trusted Certificate Authority (CA) or generate a self-signed certificate (not recommended for production environments).
  2. Place the certificate files (e.g., certificate.crt and private.key) in a secure location on your server.
  3. Modify the Nginx configuration file (/etc/nginx/sites-available/odoo) to enable SSL/TLS:
server {
    listen 443 ssl;
    server_name YOUR_SERVER_IP;
    ssl_certificate /path/to/certificate.crt;
    ssl_certificate_key /path/to/private.key;
    # Other Nginx configuration...
}

Replace /path/to/certificate.crt and /path/to/private.key with the actual paths to your SSL/TLS certificate and private key files, respectively.

  1. Restart Nginx:
$ sudo systemctl restart nginx

After enabling SSL/TLS, you can access your Odoo instance securely over HTTPS (e.g., https://YOUR_SERVER_IP).

Enabling Email Integration

Odoo provides built-in email integration for features like sending quotations, invoices, and other notifications. To enable email integration, you need to configure an SMTP server in Odoo.

  1. Log in to the Odoo web interface as an administrator.
  2. Navigate to Settings > Technical > Email > Outgoing Mail Server.
  3. Configure the SMTP server details, such as the SMTP server address, port, encryption method, and authentication credentials.
  4. Save the configuration.

With email integration enabled, Odoo can send emails directly from the application for various purposes, such as notifying customers, sending reports, and more.

Updating Odoo

Odoo releases new versions regularly, offering bug fixes, security updates, and new features. To update your Odoo installation to the latest version, follow these steps:

  1. Stop the Odoo service:
$ sudo systemctl stop odoo
  1. Navigate to the Odoo directory:
$ cd ~/odoo/odoo
  1. Update the Odoo source code by pulling the latest changes from the Git repository:
$ git pull
  1. Update the Python dependencies:
$ ~/odoo/odoo-venv/bin/pip install -r requirements.txt
  1. Start the Odoo service:
$ sudo systemctl start odoo
  1. Clear your web browser’s cache and reload the Odoo web interface to ensure you’re running the latest version.

Conclusion

Installing Odoo on Ubuntu or Debian can be a straightforward process if you follow the steps outlined in this article. With Odoo up and running, you’ll have access to a powerful suite of business applications that can streamline your operations and improve efficiency.

Remember to regularly update Odoo to benefit from the latest features, bug fixes, and security improvements. Additionally, consider implementing advanced configurations, such as running Odoo as a service, using a reverse proxy, enabling SSL/TLS encryption, and configuring email integration, to enhance the performance, security, and usability of your Odoo installation.

If you encounter any issues or have specific requirements, refer to the official Odoo documentation or seek assistance from the Odoo community forums and resources.

LEAVE A COMMENT