X
    Categories: Tutorials

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


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.

View Comments

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

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

  • 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?

  • 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

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

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

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

    • Can you open your Odoo at: http://yourIP:8069, if yes then check the nginx error log file for details.

      • Can you open your Odoo at: http://yourIP:8069, if yes then check the nginx error log file for details.

  • 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?

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

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

  • 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

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

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

    • 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

      • 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

  • 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

    • 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
      

      • 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
        

    • 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
      

      • 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
        

  • 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 !