Install Odoo (formerly OpenERP) with Nginx on an Ubuntu VPS

odoo
In today’s post we will explain you how you can easily install Odoo with Nginx as a reverse proxy server on a Ubuntu VPS.
Odoo (formerly OpenERP) is a suite of open source Business apps. Some of the modules included in Odoo are: E-commerce, Accounting & Finance, Expense Management, Calendar ..etc.

Update your system

To update your system run the following commands:

$ sudo apt-get update
$ sudo apt-get upgrade -y

Install Odoo (formerly OpenERP)

Add the repository to your sources list

$ vim /etc/apt/sources.list
deb http://nightly.openerp.com/7.0/nightly/deb/ ./

and install Odoo

$ sudo apt-get update
$ sudo apt-get install openerp -y

Install PostgreSQL Server

$ sudo apt-get install postgresql -y
$ sudo su - postgres -c "createuser -s openerp" 2> /dev/null || true

Set the password for the openerp postgres user

sudo su postgres
psql template1
ALTER ROLE openerp WITH password 'odooPassWord';
\q

Install and Configure Nginx

$ sudo apt-get install nginx

Generate ssl certificate

$ sudo mkdir /etc/nginx/ssl
$ cd /etc/nginx/ssl
$ sudo openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
$ sudo openssl rsa -passin pass:x -in server.pass.key -out server.key
$ sudo rm server.pass.key
$ sudo openssl req -new -key server.key -out server.csr
$ sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Create Nginx server block

$ sudo vim /etc/nginx/sites-available/yourOdooSite.com
upstream oddo {
    server 127.0.0.1:8069;
}

server {
    listen      443 default;
    server_name yourOdooSite.com;

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

    ssl on;
    ssl_certificate     /etc/nginx/ssl/server.crt;
    ssl_certificate_key /etc/nginx/ssl/server.key;
    keepalive_timeout   60;

    ssl_ciphers             HIGH:!ADH:!MD5;
    ssl_protocols           SSLv3 TLSv1;
    ssl_prefer_server_ciphers on;

    proxy_buffers 16 64k;
    proxy_buffer_size 128k;

    location / {
        proxy_pass  http://oddo;
        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 ~* /web/static/ {
        proxy_cache_valid 200 60m;
        proxy_buffering on;
        expires 864000;
        proxy_pass http://oddo;
    }
}

server {
    listen      80;
    server_name yourOdooSite.com;

    add_header Strict-Transport-Security max-age=2592000;
    rewrite ^/.*$ https://$host$request_uri? permanent;
}

Activate the server block by creating a symbolic link and restart nginx

$ sudo ln -s /etc/nginx/sites-available/yourOdooSite.com /etc/nginx/sites-enabled/yourOdooSite.com
$ sudo /etc/init.d/nginx restart

Configure the ODOO application

Edit the server configuration

/etc/openerp/openerp-server.conf

and set the password

db_password = odooPassWord

Create a New Database

Open your browser, go to https://yourOdooSite.com, fill the input fields and click on the “Create Database” button.

After the database is created, you will be redirected to the admin panel where you can change your password.

Of course, you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install Odoo for you. They are available 24×7 and will take care of your request immediately. Alternatively, you may also refer to our guide on How to Install Odoo 12 on Ubuntu 18.04 with Nginx as a Reverse Proxy.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

26 thoughts on “Install Odoo (formerly OpenERP) with Nginx on an Ubuntu VPS”

  1. Thanks so much for this article, I was able to setup Odoo on nginx with it.

    I would like to point out a bug in the source, In the “generate ssl certificate” section and server block you have different routes for the ssl certificates:

    /etc/nginx/ssl
    /etc/ssl/nginx/

    After I solved that everything worked fine.

    Reply
  2. Nicely laid out, but before I try it I notice that you made no mention of installing all or any of the required dependencies for Odoo 8.0 to work.

    How have you covered that? Is there something you did that I missed?

    Curious to know :)

    Reply
    • To install Python Dependencies for Odoo (OpenERP) run:

      sudo apt-get install python-dateutil python-docutils python-feedparser python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-psycopg2 python-psutil python-pybabel python-pychart python-pydot python-pyparsing python-reportlab python-simplejson python-tz python-unittest2 python-vatnumber python-vobject python-webdav python-werkzeug python-xlwt python-yaml python-zsi poppler-utils python-pip

      To install supporting packages for Odoo (OpenERP) run the following:

      sudo apt-get install gcc python-dev mc bzr python-setuptools python-babel python-feedparser python-reportlab-accel python-zsi python-openssl python-egenix-mxdatetime python-jinja2 python-unittest2 python-mock python-docutils lptools make python-psutil python-paramiko poppler-utils python-pdftools antiword
      Reply
  3. Thanks for this great tutorial !

    However, I am having issues relaunching the openerp-server after a server reboot. Restarting Nginx is not working for me. Since their is no script in /etc/init.d/, I am out of idea to relaunch the openerp-server. I also checked all the pid running and Odoo is not running.

    Your help would be greatly appreciated. Thanks !

    Reply
  4. when i try

    deb http://nightly.openerp.com/7.0/nightly/deb/ ./
    so it give error
    “deb” command not found

    After i try to install openerp
    using

    sudo apt-get install openerp -y

    it gives error like,
    “E: unable to locate package openerp”

    please help for solve this issue

    Reply
    • You need to add one of the lines below in the /etc/apt/sources.list file

      deb http://nightly.odoo.com/7.0/nightly/deb/ ./ # for Odoo 7
      deb http://nightly.odoo.com/8.0/nightly/deb/ ./ # for Odoo 8
      

      and install it with:

      sudo apt-get update && sudo apt-get install openerp # for Odoo 7
      sudo apt-get update && sudo apt-get install odoo    # for Odoo 8
      
      Reply
    • You need to add one of the lines below in the /etc/apt/sources.list file

      deb http://nightly.odoo.com/7.0/nightly/deb/ ./ # for Odoo 7
      deb http://nightly.odoo.com/8.0/nightly/deb/ ./ # for Odoo 8
      

      and install it with:

      sudo apt-get update && sudo apt-get install openerp # for Odoo 7
      sudo apt-get update && sudo apt-get install odoo    # for Odoo 8
      
      Reply
    • i was fetch this eror
      please help me
      [emerg] unknown directive “tream” in /etc/nginx/sites-enabled/shivam.maateenterprise.com:1
      nginx: configuration file /etc/nginx/nginx.conf test failed

      Reply
  5. Hello,

    I did same thing in two amazon server, one is working well without any error and second server showing not found error and there is no error in log file of odoo and nginx. I did not understand where i did mistake, can you help please

    I access page by this url

    Thanks
    CSR

    Reply
    • Make sure that logging is enabled in your Odoo configuration file and the Odoo log file exists in the /var/log/ directory.

      Our recommendation is to try some of our newer guides about this which are available at https://www.rosehosting.com/blog/install-odoo-9-on-ubuntu-14-04/ and https://www.rosehosting.com/blog/install-odoo-on-a-debian-8-vps-with-nginx-as-a-reverse-proxy/.

      Thanks.

      Reply
  6. Hello and thank you for the great tutorial. In odoo you can create a website and an e-commerce webpage and those usually are public pages and there’s a login button above that let’s you login to the erp system. My question is, how can we make the public pages non HTTPS and when the user want to login, he gets redirected to HTTPS and stays in HTTPS while using the ERP system? I’m aware that he can setup another instance of odoo and sync the data but this way some integration features will be lost. Is there a way to do that on a single odoo instance?

    Reply
    • Hello Hasan. You can make your login pages redirect to HTTPS using Nginx rewrite rules. For example this code:

      if ($request_uri ~* "/login.php") {
      rewrite ^ https://$host$request_uri permanent;
      }

      It will redirect http://domain_name/login.php to https://domain_name/login.php

      For more info on Nginx rewrites please visit their official article.

      Reply
  7. I am following your tutorial to one of my servers. But I am getting 504 Gateway Time-out error.
    I have followed every step still facing the problem.
    Thanks.

    Reply
  8. pls i will love to know how to host website created using odoo v8. running perfectly well on local host. i will like to have a domain e.g www.myname.com for that site. wld be grateful if I’m helped. Thanks

    Reply
    • You’ll need to host your Odoo installation on an online server and purchase a domain name. You can sign up for our Optimized Odoo Hosting at https://www.rosehosting.com/odoo-hosting.html and our experienced Linux admins will help you install and configure your Odoo for free. After the installation and configuration process, your Odoo will be accessible online via the domain of your choice. We also offer domains, you can register a domain name at https://secure.rosehosting.com/clientarea/index.php?/checkdomain/domain-registration/

      If there’s anything else, feel free to contact us. We are available 24/7.

      Reply
  9. I can’t restart nginx server using $ sudo /etc/init.d/nginx restart, getting an error: * Restarting nginx nginx [fail]. then i ran this command sudo nginx -t output was:
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful

    how can i restart nginx?

    Reply
    • The steps in this article have been tested for Ubuntu. Although MacOS and the opensource Linux distributions share many similarities there is no way to tell this procedure will also work on MacOS.

      Reply
  10. Thank you so much for this. All seems to be working well except that I’m getting a “Not Secure Site” warning when I try to access the site. This is probably a rookie mistake. Any guidance?

    Reply
    • Most likely, this is because you are using a self-signed SSL certificate which is why your browser is complaining. You can safely ignore that, accept the certificate, proceed and open your website. Or, if you do not want to use a self-signed SSL certificate, you can order a CA issued SSL certificate at https://www.rosehosting.com/ssl-certificates.html

      Reply

Leave a Comment