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.

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.

Tutorials
How to install and configure dkim with OpenDKIM and Exim on a CentOS 7 VPS
Tutorials
How to install LEMP and run TT-RSS on a Fedora 20 VPS
Tips and Tricks
How to backup and restore your MySQL database
  • El Sonny (@el_sonny)

    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.


    • admin

      adminadmin

      Author Reply

      Thanks for noticing that. Corrected.


  • Murray

    MurrayMurray

    Author Reply

    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 :)


    • admin

      adminadmin

      Author 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

  • Gabriel Mongeau

    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 !


  • James Utru

    James UtruJames Utru

    Author Reply

    Can someone make this into a script please?


  • kartik

    kartikkartik

    Author Reply

    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


    • admin

      adminadmin

      Author 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
      

    • admin

      adminadmin

      Author 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
      

  • Randy Harkediansa

    Thanks! This post made my day!!!


    • shivam dudhat

      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


      • admin

        adminadmin

        Author Reply

        Please edit your nginx server block related to Odoo and change tream to upstream.


  • Chuvindra Singh

    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


  • Hasan Fakih

    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?


    • admin

      adminadmin

      Author 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.


  • Tanzil Khan

    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.


  • Ahmed

    AhmedAhmed

    Author Reply

    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 http://www.myname.com for that site. wld be grateful if I’m helped. Thanks


  • Kabeer

    KabeerKabeer

    Author Reply

    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?


    • admin

      adminadmin

      Author Reply

      Did you check your Nginx error log file?


  • Aphya

    AphyaAphya

    Author Reply

    Thanks for this article. Is the setup the same for MacOS?


    • admin

      adminadmin

      Author 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.