Networking

How to install Odoo ERP with NGINX on Ubuntu

Odoo is an outstanding ERP system, says Jack Wallen. He walks you through the process of installing this free open source wonder on Ubuntu with NGINX.

odoohero.jpg
Image: Jack Wallen

If you're looking for a solid Enterprise Resource Planning (ERP) system, you need not look any further than open source; within this realm there are plenty of powerhouse tools ready to serve you. One such tool is Odoo. This particular ERP tool does all of this and and more:

  • Accounting
  • CRM
  • Online billing
  • Project management
  • Issue tracking
  • Surveys
  • Social networks
  • Point of sale
  • Notes
  • Sales Management
  • Warehouse Management
  • MRP

Odoo is powerful, flexible, and best of all free. I'll walk you through the steps of getting Odoo up and running on a Ubuntu 16.04 platform with NGINX. The installation is a bit cumbersome, but the end result is worth every step.

SEE: Research: Enterprise software advantages, opportunities and challenges (Tech Pro Research)

Creating an Odoo user

The first thing we're going to do is create a user for Odoo. Open a terminal window and issue the following command:

sudo adduser —system —home=/opt/odoo —group odoo

Next, create a directory for the user with the command:

sudo mkdir -p /var/lib/odoo

Install and configure the database

Odoo depends upon PostgreSQL; your system probably doesn't include that database, so let's install it. From the terminal window, issue the command:

sudo apt-get install postgresql

Log into the PostgreSQL shell with the command su - postgres and create the roll for the Odoo user like so:

createuser —createdb —username postgres —no-createrole —no-superuser —pwprompt odoo

You'll be prompted to enter and verify a password for the user (one that will be later used to log on as the Odoo admin user, so remember this password). Once that is complete, type exit.

Install the necessary dependencies

Odoo has a lot of dependencies that can all be installed with this one command:

sudo apt-get install python-cups python-dateutil python-decorator python-docutils python-feedparser \python-gdata python-geoip python-gevent python-imaging python-jinja2 python-ldap python-libxslt1 \python-lxml python-mako python-mock python-openid python-passlib python-psutil python-psycopg2 \python-pybabel python-pychart python-pydot python-pyparsing python-pypdf python-reportlab python-requests \python-simplejson python-tz python-unicodecsv python-unittest2 python-vatnumber python-vobject \python-werkzeug python-xlwt python-yaml wkhtmltopdf

Allow those dependencies to install, and you're ready to move on.

Install Odoo

It's finally time to install Odoo. From the terminal window, issue the following command:

sudo apt-get install odoo

Once that completes, it's time to install the web server.

Install and configure NGINX

If you don't already have NGINX up and running, install it with the command:

sudo apt-get install nginx

When the installation completes, you need to configure a virtual host directory for Odoo. Create the new file /etc/nginx/sites-available/odoo with the following contents:

## Odoo Backend ##
upstream odooerp {
server 127.0.0.1:8069;
}

## https site##
server {
listen 443 default_server;
server_name odoo.mysite.co;
root /usr/share/nginx/html;
index index.html index.htm;

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

# ssl filess
ssl on;
ssl_ciphers ALL:!ADH:!MD5:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_certificate /etc/nginx/ssl/odoo.crt;
ssl_certificate_key /etc/nginx/ssl/odoo.key;

# proxy buffers
proxy_buffers 16 64k;
proxy_buffer_size 128k;

## odoo proxypass with https
## location / {
proxy_pass http://odooerp;
# force timeouts if the backend dies
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;

# set headers
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;
}

# cache some static data in memory for 60mins
location ~* /web/static/ {
proxy_cache_valid 200 60m;
proxy_buffering on;
expires 864000;
proxy_pass http://odooerp;
}
}

## http redirects to https ##
server {
listen 80;
server_name odoo.mysite.co;

# Strict Transport Security
add_header Strict-Transport-Security max-age=2592000;
rewrite ^/.*$ http://odooerp; permanent;
}

Save and exit the file. Create a link from sites-available to sites-enabled with the command:

ln -s /etc/nginx/sites/available/odoo /etc/nginx/sites-enabled/odoo

Now test the configuration with the command nginx -t, which should return no errors. Restart NGINX with the command sudo service nginx restart.

Create an SSL certificate

We need to create a new ssl certificate to be used by Odoo. First create the necessary directory with the command sudo mkdir -p /etc/nginx/ssl. Change into that directory with the command cd /etc/nginx/ssl and generate a self-signed certificate with the command:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/odoo.key -out /etc/nginx/ssl/odoo.crt

Answer all the usual ssl-creation questions. Once that process completes, change the permissions of the certificate file with the command sudo chmod 600 odoo.key.

Configure Odoo

You finally get to fire up a web browser and point it to http://IP_OF_SERVER:8069 (IP_OF_SERVER is the actual IP address of the server). In the resulting window (Figure A), enter the information for your database.

Figure A

Figure A
Image: Jack Wallen
Setting up the Odoo database.

It is important to know that the Master password for the setup is admin. Beyond that, you can name the database whatever you like and create a password for the database. Click Create Database, and the installation will complete. You'll be on the Odoo admin dashboard (Figure B), and you can start adding whatever modules necessary to create your new ERP solution.

Figure B

Figure B
Image: Jack Wallen
The Odoo dashboard, ready to serve.

If you need to log back in as the administrator, remember the username is admin, and the password is whatever you created when you created the PostgreSQL Odoo role.

Keep expanding

With the Odoo ERP solution you can create a one-stop-shop for your company or just a single-purpose system. Whatever your ERP needs, Odoo can meet them. Expand the platform as you grow, and you should find Odoo will continue to meet your demands.

Also see

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox