We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

How to Install Odoo 13 on Ubuntu 18.04 with Nginx – AWS

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

Odoo is a management self hosted software to run a business with a top notch user experience. The applications within Odoo are perfectly integrated with each other, allowing you to fully automate your business processes easily.

Advanced and easy tutorial to Install Odoo using Docker with Nginx and SSL

Prerequisites

  1. A running EC2 Instance. Learn how to create an AWS EC2 instance.
  2. Assigned a Elastic IP to your EC2 Instance.
  3. Setup Amazon RDS and connect it with EC2 Instance (Please choose PostgreSQL for Engine).
  4. Setup and configure Route 53 and point your domain to AWS.
  5. Successful SSH connection to your EC2 Instance.

SSH to your EC2 Instance and perform the steps listed below.

Step 1: Initial Server Setup

Let’s start by updating the local package index with the following command to the latest available version.

sudo apt update
sudo apt upgrade

Once the update is done you can start installing the required packages.

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 2020-02-14 09: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
 Feb 14 09: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 = RDS_ENDPOINT
db_port = False
db_user = RDS_user
db_password = RDS_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 directory 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

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

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

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

Cart

Your Cart is Empty

Back To Shop