Odoo is free, open source, ERP software written in Python and Javascript framework. It is used by more than 7 million users worldwide stretching startups to large enterprise users (300,000+ users). Odoo is the most installed management software in the world. ERP is now compulsory in most countries.
Below is a guide for you to install Odoo in the Ubuntu 20.04 LTS server
Step 1 : Install Ubuntu Essentials
First, we will be updating our existing packages and enabling few dependency repos for Odoo.
sudo apt install software-properties-common -y
sudo add-apt-repository universe
# libpng12-0 dependency for wkhtmltopdf
sudo add-apt-repository ppa:linuxuprising/libpng12 -y
sudo add-apt-repository "deb http://mirrors.kernel.org/ubuntu/ xenial main"
sudo apt update
sudo apt upgrade -y
Step 2 : Install Postgresql Server
Odoo uses postgresql database to store the data. We can use the below command to install postgresql 12 version which comes by default in Ubuntu 22.04. Postgresql versions 13, 14, 15 are also compatible with Odoo 16.
sudo apt install postgresql postgresql-server-dev-all -y
#Creating the ODOO PostgreSQL User
sudo su - postgres -c "createuser -s odoo16"
Step 3 : Install Python Dependencies
#Installing Python 3 + pip3
sudo apt install git python3 python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less libjpeg-dev gdebi xfonts-base xfonts-75dpi -y
sudo apt install libpng12-0 -y
#Installing nodeJS NPM and rtlcss for LTR support
sudo apt install nodejs npm -y
sudo npm install -g rtlcss
sudo npm install -g less
sudo npm install -g less-plugin-clean-css
Step 4 : Install wkhtmltopdf
wkhtmltopdf is used to convert html content into pdf format. Odoo generates the reports in html format and this is then converted to pdf using the wkhtmltopdf package.
sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.focal_amd64.deb
sudo apt install ./wkhtmltox_0.12.5-1.focal_amd64.deb
Step 5 : Create ODOO system user
sudo adduser --system --quiet --shell=/bin/bash --home=/opt/odoo --gecos 'ODOO' --group odoo
# The user should also be added to the sudo'ers group.
sudo adduser odoo sudo
Step 6 : Create Log Directory
We will be storing the logs of our Odoo instance in this directory.
sudo mkdir /var/log/odoo
sudo chown odoo:odoo /var/log/odoo
Step 7 : Cloning Odoo to Server
Now we need to get the source code of Odoo so that we can run it in our server.
sudo git clone --depth 1 --branch 16.0 https://github.com/odoo/odoo /opt/odoo/odoo16/server-addons
Step 8 : Setup python virtual environment
We will be installing the required python packages for Odoo in a python virtual environment. Let us create and activate a python virtual environment.
sudo pip3 install virtualenv
cd /opt/odoo/odoo16
virtualenv odoo-venv or python3 -m venv odoo-venv
source odoo-venv/bin/activate
Step 8 : Install python packages/requirements
pip3 install -r /opt/odoo/odoo16/server-addons/requirements.txt
pip3 install psycopg2-binary pdfminer.six num2words ofxparse dbfread ebaysdk firebase_admin pyOpenSSL
Step 9 : Setting permissions on home folder
sudo chown -R odoo:odoo /opt/odoo/*
Step 10 : Create custom module directory
sudo su odoo -c "mkdir /opt/odoo/odoo16/odoo-custom-addons"
Step 11 : Create server config file
Details of the database, port number to run Odoo, logfile location etc. can be listed in a config file which will be used by Odoo during the run time.
sudo touch /etc/odoo16.conf
sudo nano /etc/odoo16.conf
[options]
; Database operations password:
admin_passwd = PASSWORD
db_host = localhost
db_user = odoo16
db_password = False
http_port = 8069
logfile = /var/log/odoo/odoo16-server.log
data_dir = /opt/odoo/odoo16/.local/share/Odoo
addons_path = /opt/odoo/odoo16/server-addons/addons,/opt/odoo/odoo16/odoo-custom-addons
Step 12 : Set permission for config file
sudo chown odoo:odoo /etc/odoo16.conf
sudo chmod 640 /etc/odoo16.conf
Step 13 : Create service file
This service file will ensure that our Odoo system is up and running after every server restart.
sudo nano /etc/systemd/system/odoo16.service
[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/odoo16/odoo-venv/bin/python3 /opt/odoo/odoo16/server-addons/odoo-bin -c /etc/odoo16.conf
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target
Step 14 : Set permission for service file
sudo chmod 755 /etc/systemd/system/odoo16.service
sudo chown root: /etc/systemd/system/odoo16.service
Step 15 : Service Commands
sudo systemctl start odoo16.service
sudo systemctl status odoo16.service
sudo systemctl restart odoo16.service
sudo systemctl daemon-reload
Step 16 : Enable the Odoo service on system startup
sudo systemctl enable odoo16.service