Install Odoo on Ubuntu and Debian
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 Install Odoo on Ubuntu and Debian-based Linux distributions.
Prerequisites
Before we begin, ensure that you have the following prerequisites in place:
- Update the package lists:
$ sudo apt update
$ sudo apt upgrade
- Verify that Python 3 is installed:
$ 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
- Install PostgreSQL:
$ 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:
- Switch to the
postgres
user:
$ sudo su postgres
- Create a new PostgreSQL user for Odoo:
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo
Enter a secure password when prompted.
- Create a database for Odoo:
createdb --username postgres --owner odoo --encoding UTF8 --template template0 odoo
- Exit the
postgres
user session:
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.
- Install the necessary 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
- Create a directory for Odoo and navigate into it:
$ mkdir ~/odoo
$ cd ~/odoo
- 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.
- Create a virtual environment:
$ python3 -m venv odoo-venv
$ source odoo-venv/bin/activate
- Install the required Python packages:
$ pip install -r odoo/requirements.txt
- Install additional Python packages:
$ 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.
- Create a configuration directory and file:
$ mkdir ~/odoo/config
$ nano ~/odoo/config/odoo.conf
- Add the following configuration settings to the
odoo.conf
file:
[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 and YOUR_ODOO_PASSWORD
with the password you set for the odoo
PostgreSQL user.
- Save and close the
odoo.conf
file.
Step 4: Start Odoo
Now that you’ve installed and configured Install Odoo on Ubuntu and Debian, you can start the Odoo server.
- Navigate to the Odoo directory:
$ cd ~/odoo/odoo
- 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.
- Open your web browser and enter the following URL:
http://localhost:8069
You should see the Odoo login page.
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.
- Create a system user for Odoo:
$ sudo adduser --system --no-create-home --group odoo
- Create a systemd service file for Odoo:
$ sudo nano /etc/systemd/system/odoo.service
- Add the following configuration to the
odoo.service
file:
[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
Replace YOUR_USERNAME
with your actual username on the system.
- Reload the systemd daemon:
$ sudo systemctl daemon-reload
- Enable the Odoo service to start on boot:
$ sudo systemctl enable odoo
- Start the Odoo service:
$ sudo systemctl start odoo
- Check the status of the Odoo service:
$ sudo systemctl status 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:
- Install Nginx:
$ sudo apt install nginx
- Create a new Nginx configuration file for Odoo:
$ sudo nano /etc/nginx/sites-available/odoo
- Add the following configuration to the
odoo
file:
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;
}
}
Replace YOUR_SERVER_IP
with your server’s IP address or domain name.
- Create a symbolic link to enable the Odoo configuration:
$ sudo ln -s /etc/nginx/sites-available/odoo /etc/nginx/sites-enabled/
- Remove the default Nginx configuration:
$ sudo rm /etc/nginx/sites-enabled/default
- Restart Nginx:
$ sudo systemctl restart nginx
- Add
longpolling_port
to your Odoo configuration file.
longpolling_port = 8072
- Restart Odoo
$ 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 Install Odoo on Ubuntu and Debian 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:
- Modify the Nginx configuration file for Odoo:
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. You can obtain a free SSL/TLS certificate from Let’s Encrypt.
- 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.
- Log in to your Odoo instance as an administrator.
- Navigate to Settings > General Settings.
- Under the "Discuss" section, configure the outgoing email server settings (SMTP server, port, username, password, etc.).
- Test the email configuration by sending a test email.
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:
- Stop the Odoo service:
$ sudo systemctl stop odoo
- Navigate to the Odoo directory:
$ cd ~/odoo/odoo
- Pull the latest changes from the Git repository:
$ git pull
- Update the Python packages:
$ ~/odoo/odoo-venv/bin/pip install -r requirements.txt
- Start the Odoo service:
$ sudo systemctl start odoo
- Update database modules from Odoo web interface.
Alternative Installation Methods for Install Odoo on Ubuntu and Debian
While installing Odoo from source provides maximum flexibility, alternative methods exist that can simplify the process, especially for simpler deployments or when using specific Odoo versions. Here are two different approaches:
1. Using Docker:
Docker containers provide a consistent and isolated environment for running applications. This eliminates many dependency-related issues and simplifies deployment.
-
Explanation: Docker packages Odoo and its dependencies into a single container. You don’t need to manually install PostgreSQL or Python. Docker handles everything. This method is particularly useful for testing or deploying multiple Odoo instances with different configurations.
-
Steps:
-
Install Docker: If you don’t have Docker installed, follow the official Docker documentation for Ubuntu or Debian.
-
Pull the Odoo Docker image:
docker pull odoo:16.0 # Replace 16.0 with your desired version
-
Create a Docker volume for persistent data (optional but highly recommended):
docker volume create odoo_data
-
Run the Odoo Docker container:
docker run -d -p 8069:8069 -p 8072:8072 --name odoo --link db:db -v odoo_data:/var/lib/odoo -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=YOUR_ODOO_PASSWORD odoo:16.0
Explanation of the command:
-d
: Runs the container in detached mode (background).-p 8069:8069 -p 8072:8072
: Maps ports 8069 (Odoo web interface) and 8072 (longpolling) from the container to the host.--name odoo
: Assigns the name "odoo" to the container.--link db:db
: Links the Odoo container to a PostgreSQL container named "db". Important: If you’re not using a separate PostgreSQL container, remove this and configure Odoo to connect to your existing PostgreSQL instance directly. You’ll need to modify theodoo.conf
file within the container, which is more involved.-v odoo_data:/var/lib/odoo
: Mounts the "odoo_data" volume to the Odoo data directory within the container. This ensures data persistence across container restarts.-e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=YOUR_ODOO_PASSWORD
: Sets environment variables for the PostgreSQL user and password. ReplaceYOUR_ODOO_PASSWORD
with the actual password.
-
(Optional) Run a PostgreSQL Docker container: If you don’t have a PostgreSQL server running, you can run one in Docker:
docker run -d --name db -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=YOUR_ODOO_PASSWORD -e POSTGRES_DB=odoo -v db_data:/var/lib/postgresql/data postgres:13
-v db_data:/var/lib/postgresql/data
: Mounts thedb_data
volume to persist the database data.
-
Access Odoo: Open your web browser and navigate to
http://localhost:8069
.
-
2. Using Odoo.sh (Odoo’s Cloud Platform):
Odoo.sh is Odoo’s official cloud platform. It automates the entire deployment and management process, including server setup, database configuration, backups, and updates.
-
Explanation: Odoo.sh eliminates the need for manual server configuration. It provides a fully managed Odoo environment. This option is ideal for businesses that want to focus on using Odoo rather than managing its infrastructure. It comes with integrated development and testing environments.
-
Steps:
-
Sign up for an Odoo.sh account: Visit https://www.odoo.sh/ and create an account. Odoo.sh offers a free trial.
-
Connect to GitHub: Link your GitHub account to Odoo.sh. This allows you to deploy your custom Odoo modules.
-
Create a new project: Follow the Odoo.sh wizard to create a new project. You’ll be prompted to select your Odoo version and database configuration.
-
Deploy your Odoo instance: Odoo.sh automatically sets up the server, database, and Odoo instance.
-
Access your Odoo instance: Odoo.sh provides a URL to access your deployed Odoo instance.
-
-
Code Example: There is no direct code example because Odoo.sh handles the underlying infrastructure. Configuration is done through the Odoo.sh web interface. You’ll primarily interact with code when developing custom Odoo modules, which are then pushed to your GitHub repository and automatically deployed by Odoo.sh.
Conclusion
Install Odoo on Ubuntu and 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. The Docker and Odoo.sh options provide easier alternatives.
Remember to regularly update Install Odoo on Ubuntu and Debian 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 Install Odoo on Ubuntu and Debian 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.