Compute Engine Google Cloud

Install Odoo 13 on Ubuntu 18.04 with Nginx – Google Cloud

Install Odoo 13 on Ubuntu 18.04 with Nginx – Google Cloud. In this tutorial you are going to learn how to install and setup Odoo with Nginx reverse proxy and connect it with PostgreSQL in Cloud SQL.

This setup is tested on Google Cloud Platform with the following Infrastructure.

  • Compute Engine VM Instance: 3.75 GB RAM, 10 GB SSD
  • Cloud SQL: 614 MB RAM, PostgreSQL

Learn a complete walk through of the Odoo Sales Application with tips on using advanced configurations.

Try this setup on one of the following Cloud hosting providers with free trial and low cost.

PlatformRAMSSDCost
Kamatera Cloud1 GB20 GB$4/mo
Alibaba Cloud1 GB20 GB$8/mo

Prerequisites

With the above-completed prerequisites I assume you have your instance up and running, DNS configured and Cloud SQL is authorized to allow connections from the VM Instance.

Step 1: Server Setup

Once your Ubuntu server is updated and upgraded to latest packages you can start installing Odoo.

Step 2: Install Wkhtmltopdf

Wkhtmltopdf is package that is used to render HTML to PDF and other image formats. If you are using Odoo to print PDF reports you should install wkhtmltopdf tool. The recommended version for Odoo is 0.12.5. This is not included in the default Ubuntu 18.04 repository.

So we shall download the package and install it.

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo apt install ./wkhtmltox_0.12.5-1.bionic_amd64.deb

Step 3: Install Odoo 13

Now you can install Odoo 13 by adding the repository to your Ubuntu server.

wget -O - https://nightly.odoo.com/odoo.key | sudo apt-key add -
echo "deb http://nightly.odoo.com/13.0/nightly/deb/ ./" | sudo tee /etc/apt/sources.list.d/odoo.list

Update the apt cache and proceed install Odoo13.

sudo apt update
sudo apt install odoo

Once the installation is complete Odoo is started automatically as a service.

To make sure Odoo is running you can check the status using the following command.

sudo service odoo status
Output
● odoo.service - Odoo Open Source ERP and CRM
    Loaded: loaded (/lib/systemd/system/odoo.service; enabled; vendor preset: enabled)
    Active: active (running) since Wed 2019-10-23 10:29:38 UTC; 10min ago
  Main PID: 8387 (odoo)
     Tasks: 6 (limit: 4395)
    CGroup: /system.slice/odoo.service
            └─8387 /usr/bin/python3 /usr/bin/odoo --config /etc/odoo/odoo.conf --logfile /var/log/odoo/odoo-server.log
 Oct 23 10:29:38 odoo systemd[1]: Started Odoo Open Source ERP and CRM.

This indicates Odoo is started and running successfully.

Now you can enable Odoo service to start on system boot.

sudo systemctl enable --now odoo

Step 4: Configure Cloud SQL – PostgreSQL

Now you can configure Odoo to use remote database like Cloud SQL or Amazon RDS.

sudo nano /etc/odoo/odoo.conf

Replace the highlighted values corresponding to your Cloud SQL values.

[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = CloudSQL_Public_IP
db_port = False
db_user = CloudSQL_user
db_password = CloudSQL_user_password
;addons_path = /usr/lib/python3/dist-packages/odoo/addons

Restart Odoo.

sudo service odoo restart

Step 5: Install Nginx

Install Nginx using the followng command.

sudo apt install nginx

Remove default Nginx configurations.

sudo rm /etc/nginx/sites-enabled/default
sudo rm /etc/nginx/sites-available/default

Step 6: Configure Nginx Reverse proxy for Odoo

Create a new Nginx configuration for Odoo in the sites-available directory.

 sudo nano /etc/nginx/sites-available/odoo.conf

Copy and paste the following configuration, ensure that you change the server_name to match your domain name.

upstream odooserver {
     server 127.0.0.1:8069;
}

server {
     listen 80;
     server_name domainname.com;

     access_log /var/log/nginx/odoo_access.log;
     error_log /var/log/nginx/odoo_error.log;

     proxy_read_timeout 720s;
     proxy_connect_timeout 720s;
     proxy_send_timeout 720s;
     proxy_set_header X-Forwarded-Host $host;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Proto $scheme;
     proxy_set_header X-Real-IP $remote_addr;

     location / {
        proxy_redirect off;
        proxy_pass http://odooserver;
     }

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

     gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
     gzip on;
 }

Hit Ctrl+X followed by Y and Enter to save the file and exit.

To enable this newly created website configuration, symlink the file that you just created into the sites-enabled directory.

sudo ln -s /etc/nginx/sites-available/odoo.conf /etc/nginx/sites-enabled/odoo.conf

Check your configuration and restart Nginx for the changes to take effect.

sudo nginx -t
sudo service nginx restart

Step 7: Install and configure SSL for Odoo

HTTPS
HTTPS is a protocol for secure communication between a server (instance) and a client (web browser). Due to the introduction of Let’s Encrypt, which provides free SSL certificates, HTTPS are adopted by everyone and also provides trust to your audiences.

sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install python-certbot-nginx

Now we have installed Certbot by Let’s Encrypt for Ubuntu 18.04, run this command to receive your certificates.

sudo certbot --nginx certonly

Enter your email and agree to the terms and conditions, then you will receive the list of domains you need to generate SSL certificate.

To select all domains simply hit Enter

The Certbot client will automatically generate the new certificate for your domain. Now we need to update the Nginx config.

Redirect HTTP Traffic to HTTPS

Open your site’s Nginx configuration file add replace everything with the following. Replacing the file path with the one you received when obtaining the SSL certificate. The ssl_certificate directive should point to your fullchain.pem file, and the ssl_certificate_key directive should point to your privkey.pem file.

 upstream odooserver {
     server 127.0.0.1:8069;
 }

 server {
     listen [::]:80;
     listen 80;

     server_name domainname.com www.domainname.com;

     return 301 https://domainname.com$request_uri;
 }

 server {
     listen [::]:443 ssl;
     listen 443 ssl;

     server_name www.domainname.com;

     ssl_certificate /etc/letsencrypt/live/domainname.com/fullchain.pem;
     ssl_certificate_key /etc/letsencrypt/live/domainname.com/privkey.pem;

     return 301 https://domainname.com$request_uri;
 }

 server {
     listen [::]:443 ssl http2;
     listen 443 ssl http2;

     server_name domainname.com;

     ssl_certificate /etc/letsencrypt/live/domainname.com/fullchain.pem;
     ssl_certificate_key /etc/letsencrypt/live/domainname.com/privkey.pem;

     access_log /var/log/nginx/odoo_access.log;
     error_log /var/log/nginx/odoo_error.log;

     proxy_read_timeout 720s;
     proxy_connect_timeout 720s;
     proxy_send_timeout 720s;
     proxy_set_header X-Forwarded-Host $host;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Proto $scheme;
     proxy_set_header X-Real-IP $remote_addr;

     location / {
        proxy_redirect off;
        proxy_pass http://odooserver;
     }

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

     gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
     gzip on;
 }

Hit CTRL+X followed by Y to save the changes.

Check your configuration and restart Nginx for the changes to take effect.

sudo nginx -t
sudo service nginx restart

Renewing SSL Certificate

Certificates provided by Let’s Encrypt are valid for 90 days only, so you need to renew them often. Now you set up a cronjob to check for the certificate which is due to expire in next 30 days and renew it automatically.

sudo crontab -e

Add this line at the end of the file

0 0,12 * * * certbot renew >/dev/null 2>&1

Hit CTRL+X followed by Y to save the changes.

This cronjob will attempt to check for renewing the certificate twice daily.

Step 8: Setup Odoo

Now you can visit your domain name on your web browser. You will see the page similar to the one below. Here you can create the database and admin user for your Odoo.

Odoo Setup

Fill in all appropriate values and click create database. Now Odoo will be ready to use.

Odoo Dashboard

Conclusion

Now you have learned how to install Odoo 13 on your Ubuntu server with Nginx in Google Cloud and secure it with Let’s Encrypt.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Cloudbooklet builds a large collection of Linux based guides and tutorials on Cloud platforms like Google Cloud, AWS, Azure, DigitalOcean and more

5 Comments

    • Cloudbooklet Reply

      Ah, yes. Thank you. But this is just a guide to install Odoo

    • I believe anyone that’s landed here already has a clue what Odoo is and how to set it up on your localhost…

      • But I liked your tutorial, I was skimming looking for how to create a custom dashboard in Odoo and stumbled upon this. Nice read. I’ll raise up any queries if any…

        • Cloudbooklet Reply

          Glad to hear you liked the post. Thank you

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.