DEV Community

Chetan Mittal
Chetan Mittal

Posted on • Originally published at blog.chetanmittaldev.com on

How to Easy Install Odoo 16 on Ubuntu 22.04 hosted on a Digitalocean Droplet

Odoo 16 on Ubuntu 22.04 on Digital Droplet

Odoo, previously known as OpenERP, is one of the earlier open-source ERP systems launched in 2008 by Belgian software programmer Fabien Pinckaers.

Fabien started developing an ERP system, TinyERP, based on Python in 2005 which was later renamed to OpenERP in 2008 and then later renamed to Odoo in 2014.

I experienced OpenERP for the first time in mid-2010 when I needed to install it for a client of mine who was in the business of wine manufacturing in Italy. This client of mine had many of his business friends and competitors using OpenERP at the time.

I still remember marketing India-based ERPNext to the client but she was really interested in getting OpenERP for her business. ERPNext lacked many features at that time and didn't have a nice responsive UI.

Since then both ERPNext and Odoo have grown into full-fledged ERP systems competing with SAP, and the like.

The only thing I don't like about Odoo is that it is not 100% Open Source like ERPNext. I would always prefer using ERPNext myself over Odoo because I get almost all the features Odoo Enterprise has in ERPNext for free.

However, it is always a personal choice to pick one software over the other.

Let us move on to installing Odoo on Ubuntu 22.04 hosted on a Digitalocean droplet:-

Preparation

The very first thing we will do is to create a new droplet on Digitalocean. If you already have an account on Digitalocean then just open it in a new browser window and login into your account.

If you are new to Digitalocean then I would recommend you to sign up on it as it is the best VPS provider with a nice and easy dashboard to manage and monitor your virtual servers, also called droplets.

Create new droplet

Once you are inside your account dashboard on Digitalocean then just hit the "Create" button and select "Droplet" from the dropdown as shown in the image below:-

For this step-by-step guide, to installing Odoo version 16 on Ubuntu 22.04 LTS on a Digitalicean droplet, I will create a droplet in my Digitalocean account and then later delete it once the guide is complete.

On the "Create Droplet" page you can configure your virtual server. I usually recommend using a regular droplet with 4GB RAM, however, for this guide I will use a regular droplet with 2GB RAM and a SWAP of 4GB.

First, select the region where you want Digitalocean to host your server. I usually select either Bangalore or Singapore because these 2 locations are closest to me.

Second, select Ubuntu 22.04 LTS as the operating system for your droplet. I usually pick the LTS version of Ubuntu for the server because it receives updates for a long time of 5 years.

Third, select the size of the droplet. I usually select a "Basic" and "Regular" server with 4GB of RAM, however, for this guide we will go for a 2GB RAM droplet as shown in the image below:-

Fourth, add your SSH public key to access the server using Putty if you are on Windows or by simply running ssh username@-your-server-ip-address- on your Terminal, if you are on Linux or Mac.

Finally, we will hit the "Create Droplet" button to create our 2GB virtual server with Ubuntu 22.04 LTS on Digitalocean to install Odoo 16.

You can add tags to your droplet if you have many droplets and you need to differentiate this one from the others for an easy search. And, also change the hostname provided by Digitalocean by default. I just leave it as it is.

Next move on to the next step which is installing preliminary software such as Python, etc. required to install Odoo on Ubuntu.

Login to your droplet using SSH

Once your droplet is created then login into it using ssh root@-your-droplet-ip-address- as shown in the image below:-

Before installing software from scratch on my droplets I usually prefer creating a SWAP image of twice the size of server RAM to be on the safe side just in case some software process needs more memory power to execute.

Create a SWAP image of 4GB for your droplet

Follow the guide here to add swap: https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-22-04.

Verify if you already have a SWAP by running free -h on your server:-

As you can see we don't have any SWAP image as yet. Let's create one.

Create a 4GB SWAP image by running the commands as shown below along with images:-

$ sudo fallocate -l 4G /swapfile

$ ls -lh /swapfile

$ sudo chmod 600 /swapfile

$ ls -lh /swapfile

$ sudo mkswap /swapfile

$ sudo swapon /swapfile

$ sudo swapon --show

$ free -h

$ sudo cp /etc/fstab /etc/fstab.bak

$ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

You can also tune your SWAP image by updating its values of "Swappiness" and "Cache Pressure".

Update and Upgrade your Ubuntu Server Droplet

First, let us check if your server is on Ubuntu 22.04 or not by running the following command inside your server's terminal.

$ lsb_release -a

Once we have confirmed that our server is running Ubuntu 22.04 update your server by running:-

$ sudo apt update && sudo apt upgrade

After your server update, reboot it and then log in again.

$ reboot

$ ssh root@-your-droplet-ip-address-

Add a System User to Install Odoo 16 on your Ubuntu 22.04 Server Droplet

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

Install Software Dependencies for Odoo 16

$ sudo apt install build-essential wget git python3-pip python3-dev python3-venv python3-wheel libfreetype6-dev libxml2-dev libzip-dev libsasl2-dev python3-setuptools libjpeg-dev zlib1g-dev libpq-dev libxslt1-dev libldap2-dev libtiff5-dev libopenjp2-7-dev

Install PostgreSQL Database

$ sudo apt install PostgreSQL

Add the system user odoo16 we created earlier to the PostgreSQL database to manage our Odoo 16 database:-

$ sudo su - postgres -c "createuser -s odoo16"

Install wkhtmltopdf for generating PDFs such as Invoices

$ sudo apt install wkhtmltopdf

Now, our Ubuntu 22.04 droplet is created, configured, and prepared to install Odoo 16. Let's install it next.

Install Odoo 16

The default software installer in Ubuntu 22.04 installs Odoo 14 but we need to install Odoo 16, right? As we already know Odoo is built using Python software programming language thus let us install Odoo version 16 by using a feature in Python called "Virtual Environment".

To do this you will need to login into your system by logging in using the system user odoo16 we created earlier:-

$ sudo su - odoo16

Once you are logged in using odoo16 system user, you will need to download Odoo16 software from its Github repo located at https://www.github.com/odoo/odoo.

$ git clone https://www.github.com/odoo/odoo --depth 1 --branch 16.0 odoo16

Now, create a new Python Virtual Environment inside which we will run Odoo 16:-

$ python3 -m venv odoo16-venv

Once you have your Python Virtual Environment for Odoo 16 installed you will need to activate it:-

$ source odoo16-venv/bin/activate

Finally, let us move ahead with installing Odoo 16. Run the following:-

(odoo16-venv) odoo16@ubuntu-s-1vcpu-2gb-blr1-01:~$ pip3 install wheel

(odoo16-venv) odoo16@ubuntu-s-1vcpu-2gb-blr1-01:~$ pip3 install -r odoo16/requirements.txt

If the above steps have run successfully on your Ubuntu 22.04 server to install Odoo 16 then you need to deactivate your Python Virtual Environment:-

(odoo16-venv) odoo16@ubuntu-s-1vcpu-2gb-blr1-01:~$ deactivate

Next, you can create a custom-addons folder inside the /opt directory at the exact location /opt/odoo16/odoo16/custom-addons for Odoo 16 installation to access any custom addons you will use if any.

$ mkdir /opt/odoo16/odoo16/custom-addons

Logout from the odoo16 system user:-

$ exit

Configure Odoo 16

Now, you will need to configure your Odoo 16 to make it run.

Create Odoo 16 config file

Open the Odoo 16 config file using a text editor such as nano:-

$ sudo nano /etc/odoo16.conf

Paste the following inside the file:-

[options]
admin_passwd = passW0rd
db_host = False
db_port = False
db_user = odoo16
db_password = False
addons_path = /opt/odoo16/odoo16/addons,/opt/odoo16/odoo16/custom-addons
xmlrpc_port = 8069

Enter fullscreen mode Exit fullscreen mode

You can change the admin_password above as per your likeliness, however, passW0rd is easy to remember for me for this guide. This is your Odoo 16's master password which you will need to create or delete databases.

Create a systemd unit file for your Odoo 16

$ sudo nano /etc/systemd/system/odoo16.service

Paste the following inside the file:-

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

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

[Install]
WantedBy=multi-user.target

Enter fullscreen mode Exit fullscreen mode

Hurray! Your Odoo 16 is now ready to run. Let's run it.

Run your Odoo 16 server

Run to reload the Odoo 16 server with the above configuration:-

$ sudo systemctl daemon-reload

Now, start the Odoo 16 server:-

$ sudo systemctl start odoo16

If you want to see the status of the Odoo 16 server then you can run:-

$ sudo systemctl status odoo16

Below is the screenshot of the Odoo 16 server running on my droplet created above:-

Below are the details I filled in to create my first database on my Odoo 16 server. I hope you can fill the same, just replace my master password (the one you entered in the /etc/odoo16.conf config previously), username, email, phone, and country with yours:-

After creating the database successfully you will see a login page as below. Here, you will enter your email id and password (filled above):-

After successful login, you will see your Odoo 16 Dashboard. I am using demo data so my dashboard might look different than yours.

You can see in the image above, the very first time you will log in you will see a dashboard listing multiple applications for you to install inside your Odoo 16 database. I installed the "CRM" application on my instance as seen in the above image.

Note:- You can create and delete many databases in a single Odoo 16 instance. You can consider a database as a separate company or business.

Install NGINX for Setting up Reverse Proxy

If you are using it for internal use then accessing it through http://IP\_address:Port would also be fine, however, you won't be able to make use of HTTPS leaving your private company data accessible to hackers.

I would recommend you use a domain name (a subdomain would be fine too e.g. erp.your_domain_name.com) to use HTTPS and make your Odoo 16 server more secure.

Install NGINX Web Server

For this you will need a Web Server either Apache or NGINX and then make it run your Odoo 16 server behind a proxy. I prefer NGINX. Login to your droplet using SSH and run the following command to install NGINX.

$ sudo apt -y install nginx

Once NGINX is installed successfully, open your droplet's IP address in your browser. You will see a page with a message saying, "Welcome to nginx!".

As the droplet being used for this guide will be deleted thus I won't be configuring any domain on it, however, for the instructions below I will use the "-your-domain-name-" placeholder. You can replace it with your real domain name while setting up your production Odoo 16 server.

Setup your Odoo 16 Server with NGINX Web Server

To set up your Odoo 16 server with NGINX you will need to create an NGINX site and then enable it with some configuration.

As you can see in the image below we only have 1 NGINX site enabled default that shows the HTML page which says, "Welcome to nginx!".

Now, create an NGINX site for your Odoo 16 server:-

$ sudo nano /etc/nginx/sites-enabled/-your-domain-name-.com

And, paste the following config in it before saving:-

upstream odoo16 {
server 127.0.0.1:8069;
}

upstream odoochat {
server 127.0.0.1:8072;
}

server {
listen 80;
server_name -your-domain-name-.com;

access_log /var/log/nginx/odoo.access.log;
error_log /var/log/nginx/odoo.error.log;

proxy_buffers 16 64k;
proxy_buffer_size 128k;

location / {
     proxy_pass http://odoo16;
     proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
     proxy_redirect off;
     proxy_set_header Host $host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Proto https;
     }

location /longpolling {
     proxy_pass http://odoochat;
     }

location ~* /web/static/ {
     proxy_cache_valid 200 60m;
     proxy_buffering on;
     expires 864000;
     proxy_pass http://odoo16;
     }
}

Enter fullscreen mode Exit fullscreen mode

Save the file and reload your NGINX server:-

$ sudo systemctl restart nginx

Access your Odoo 16 Server on -your-domain-name-.com

Voila, now you can access your Odoo 16 server on -your-domain-name-.com and start maintaining your company data.

Remember, the Open Source version (Community Edition) of Odoo doesn't have as many features as the Paid version (Enterprise Edition).

The downside is that Odoo Accounting App doesn't even allow you to maintain Journals and Ledgers in its Open Source version.

I personally prefer ERPNext.

If you want to set up HTTPS on your Odoo 16 server running on -your-domain-name-.com then you can follow this article on Digitalocean on how to configure SSL for NGINX on Ubuntu 22.04 by using Letsencrypt.

If you seem to find something not working for you then let me know in the comments below.

Top comments (1)

Collapse
 
chetanmittaldev profile image
Chetan Mittal

Whenever you are ready; there is a way I can help you:

If you're still looking for traction in your software product or service, I'd recommend starting with an affordable technical content writing package:

  1. Single Technical Article written with real and working code examples just at $399 USD only
  2. Four Technical Articles per month with FREE Content Strategy Consultation per quarter written with real and working code examples just at $1,596 USD only