How to Install Odoo on Ubuntu Linux

laptop 5822575 640

This post shows students and new users how to install Odoo on Ubuntu Linux. Odoo (formerly OpenERP) is simple and intuitive suite of open source, ERP and CRM platform for businesses and individuals who want to manage their e-Commerce, website builder, billing, accounting, invoices, orders, products and more.

If you’re looking for an open source CRM or ERP software to run your operations, Odoo should be considered.

Odoo can be installed many different ways on Ubuntu Linux. The easiest and quickest way to install Odoo is by using the official Odoo APT repositories. However, you lose control when you have Odoo install and configure settings that you may not know where and how they’re configured.

Below will show you how to download, install and use Odoo on Ubuntu Linux.

How to install Odoo package dependencies on Ubuntu Linux

To perform a custom Odoo installation, you’ll have to install packages like Git, Node.js, Pip and others. Run the commands below to install supporting dependencies to install Odoo.

sudo apt update
sudo apt install git python3-pip build-essential wget python3-dev python3-venv python3-wheel libfreetype6-dev libxml2-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less libjpeg-dev zlib1g-dev libpq-dev  libxslt1-dev libldap2-dev libtiff5-dev libjpeg8-dev libopenjp2-7-dev liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev libxcb1-dev libpq-dev

How to create Odoo system user on Ubuntu Liux

After installing the required packages above, you’ll also want to create a system account for Odoo. Running Odoo with root privileges poses great security risks.

To create system account to use with Odoo, simply run the command below to create a system account called odoo .

The account home directory will be /opt/odoo

sudo useradd -m -d /opt/odoo -U -r -s /bin/bash odoo

How to install PostgreSQL on Ubuntu Linux

Odoo uses PostgreSQL database to store its content. To get PostgreSQL installed, simply run the commands below.

sudo apt install postgresql

After installing the database server, enable and start it by running the commands below.

sudo systemctl enable --now postgresql.service

Next, create a PostgreSQL database account for Odoo. Run the commands below to create a new database account called odoodbuser.

sudo su - postgres -c "createuser -s odoodbuser"

How to Install Wkhtmltopdf on Ubuntu Linux

In order to print PDF reports, you’ll need Wkhtmltopdf. This package contains sets of open source tools render HTML into PDF and various image formats on Linux systems, including Ubuntu Linux.

To install the package, run the commands below.

cd /tmp
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo apt install ./wkhtmltox_0.12.5-1.bionic_amd64.deb

How to install and configure Odoo on Ubuntu Linux

Now that you have installed all dependencies, install and created PostgreSQL database and account, continue below to download, install and configure Odoo on Ubuntu Linux.

The first thing you’ll want to do is switch to the Odoo system account we created above by running the commands below:

sudo su - odoo

At the time of this post, the latest version of Odoo is version 15. If there is a newer version of Odoo available, you should clone that instead. To clone Odoo version 15, run the commands below.

git clone https://www.github.com/odoo/odoo --depth 1 --branch 15.0 /opt/odoo/odoo

When the download completes, change into Odoo’s directory and run the commands below to configure and install all requirements for Odoo.

cd /opt/odoo
python3 -m venv odoo-venv
source odoo-venv/bin/activate
pip3 install wheel
pip install python-ldap
pip3 install -r odoo/requirements.txt
deactivate

After that create a new directory for Odoo custom addons.

mkdir /opt/odoo/odoo-custom-addons

Exit:

exit

When you’re done, add Odoo admin password, database name and database account name to its configuration file.

Run the commands below to open Odoo’s configuration file.

sudo nano /etc/odoo.conf

Then copy and paste the lines below into the file, save and exit.

[options]
; This is the password that allows database operations:
admin_passwd = type_new_password_here
db_host = False
db_port = False
db_user = odoodbuser
db_password = False
addons_path = /opt/odoo/odoo/addons,/opt/odoo/odoo-custom-addons

Save your changes and exit

How to create a Systemd unit file on Ubuntu Linux

At this point, all should be set. What you need to do now is to create a systemd unit file to control startup, restart and shutdown Odoo services.

sudo nano /etc/systemd/system/odoo.service

Then copy and pastes the lines below into the file, save and exit

[Unit]
Description=Odoo
Requires=postgresql.service
After=network.target postgresql.service

[Service]
Type=simple
SyslogIdentifier=odoo
PermissionsStartOnly=true
User=odoo
Group=odoo
ExecStart=/opt/odoo/odoo-venv/bin/python3 /opt/odoo/odoo/odoo-bin -c /etc/odoo.conf
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

When you’re done, reload systemd daemon and start up Odoo service.

sudo systemctl daemon-reload
sudo systemctl enable --now odoo

To check Odoo status and verify it’s installed and running, run the commands below:

sudo systemctl status odoo

You should see similar messages as below:

● odoo.service - Odoo
     Loaded: loaded (/etc/systemd/system/odoo.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-10-26 23:28:23 CDT; 11s ago
   Main PID: 18386 (python3)
      Tasks: 2 (limit: 4651)
     Memory: 67.2M
     CGroup: /system.slice/odoo.service
             └─18386 /opt/odoo/odoo-venv/bin/python3 /opt/odoo/odoo/odoo-bin -c /etc/odoo.conf

Oct 26 23:28:25 ubuntu2004 odoo[18386]:     return Cursor(self.__pool, self.dbname, self.dsn, serialized=seriali>
Oct 26 23:28:25 ubuntu2004 odoo[18386]:   File "/opt/odoo/odoo/odoo/sql_db.py", line 256, in __init__
Oct 26 23:28:25 ubuntu2004 odoo[18386]:     self._cnx = pool.borrow(dsn)
Oct 26 23:28:25 ubuntu2004 odoo[18386]:   File "/opt/odoo/odoo/odoo/sql_db.py", line 588, in _locked
Oct 26 23:28:25 ubuntu2004 odoo[18386]:     return fun(self, *args, **kwargs)
Oct 26 23:28:25 ubuntu2004 odoo[18386]:   File "/opt/odoo/odoo/odoo/sql_db.py", line 654, in borrow
Oct 26 23:28:25 ubuntu2004 odoo[18386]:     result = psycopg2.connect(

That should do it if you follow and completed all the steps above..

How to login to Odoo on Ubuntu Linux

Once you see a successful status above, you can then open your browser and browse to Odoo portal using the server hostname or IP address followed by port 8069.

http://localhost:8069

You should then see Odoo setup page. Use the master password you created in /etc/odoo.conf file. then type a new database name odoodb and admin email address. then click Create database

install odoo on ubuntu linux

Use the database user account and the admin password defined in the configuration file to complete the setup. Once all is entered correctly, you should be able to complete the setup and start using Odoo.

For those who run into issues where they’re getting Internal server error or getting error when opening Odoo setup wizard, they should configure PostgreSQL to trust all local connections.

Run the commands below to open PostgreSQL configuration file.

sudo nano /etc/postgresql/12/main/pg_hba.conf

Replace the version number with the version installed on your system.

Then change the highlighted line in the file and save.

# "local" is for Unix domain socket connections only
local   all             all                    trust

Replace MD5 or Peer with trust. Save and exit, then restart PostgreSQL.

sudo service postgresql restart

If you want to use a reverse proxy with Odoo, click either link below to setup a reverse proxy with Nginx or Apache.

How to setup reverse proxy with Nginx

How to setup reverse proxy with Apache

Conclusion:

This post showed you how to install and configure Odoo on Ubuntu Linux. If you find any error or have something to add, please use the comment form below.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.