Login as root user and update the system to the latest packages
# apt update && sudo apt upgrade
Install Git, Pip, Node.js and the packages required for odoo
# apt install git python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less
Create a new user for odoo12, name it odoo12 with the home directory as /opt/odoo12 :
# useradd -m -d /opt/odoo12 -U -r -s /bin/bash odoo12
Install and Configure PostgreSQL
# apt install postgresql
Now create a PostgreSQL user with the same name as odoo user
# sudo su - postgres -c "createuser -s odoo12"
Install Wkhtmltopdf which can render HTML into PDF and various image formats. In order to print PDF reports, you will need the wkhtmltopdf tool
# wget https://builds.wkhtmltopdf.org/0.12.1.3/wkhtmltox_0.12.1.3-1~bionic_amd64.deb
# apt install ./wkhtmltox_0.12.1.3-1~bionic_amd64.deb
Once these steps are over, lets configure Odoo
Change the user into Odoo user, odoo12
# sudo su - odoo12
Git clone the odoo12 source code :
# git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 /opt/odoo12/odoo
Once the source code is downloaded, create a new Python virtual environment for the Odoo 12 installation:
# cd /opt/odoo12
# python3 -m venv odoo-venv
Next, activate the environment with the following command:
# source odoo-venv/bin/activate
Install all required Python modules with pip3:
$ pip3 install wheel
$ pip3 install -r odoo/requirements.txt
Deactivate the environment using the following command:
$ deactivate
Create a new directory for the custom addons:
$ mkdir /opt/odoo12/odoo-custom-addons
Exit to the root user
$ exit
Copy the odoo12 sample config file :
# sudo cp /opt/odoo12/odoo/debian/odoo.conf /etc/odoo12.conf
Edit the file :
# vim /etc/odoo12.conf
^ Make sure to change the Admin password to something stronger.
To run Odoo as a service we need to create a service unit file in the /etc/systemd/system/ directory.
# vim /etc/systemd/system/odoo12.service
[Unit]
Description=Odoo12
Requires=postgresql.service
After=network.target postgresql.service
[Service]
Type=simple
SyslogIdentifier=odoo12
PermissionsStartOnly=true
User=odoo12
Group=odoo12
ExecStart=/opt/odoo12/odoo-venv/bin/python3 /opt/odoo12/odoo/odoo-bin -c /etc/odoo12.conf
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target
# sudo systemctl daemon-reload
# sudo systemctl start odoo12
Enable the Odoo service to be automatically started at boot time:
# sudo systemctl enable odoo12
Now the odoo12 instalaltion would be accessible at yourdomain.com:8069
( Make sure to open the port 8069, both at server level and at public firewall level ( in case you case AWS, Alibaba etc ) )
Now to map the installation to the domain and not use port along with it, we need to have Nginx web-server configured.
Install Nginx :
# sudo apt install nginx
# sudo systemctl status nginx
Allow the firewall rules to enable Nginx :
sudo ufw allow 'Nginx Full'
Now secure the domain with SSL – you can use the free letsencrpyt SSL
# sudo add-apt-repository ppa:certbot/certbot
Install Certbot’s Nginx package with apt:
# sudo apt install python-certbot-nginx
Now obtain the SSL cert for the domain :
# certbot --nginx -d example.com -d www.example.com
Once this is done, the keys would be avaiable at :
/etc/letsencrypt/live/example.com/fullchain.pem
/etc/letsencrypt/live/example.com/privkey.pem
Now create a config file for your domain
# vim /etc/nginx/sites-enabled/example.com
Paste the following contents ( dont forget to replace domain name and the path to SSL file )
upstream odoo {
server 127.0.0.1:8069;
}
server {
listen 80;
server_name www.example.com example.com;
include snippets/letsencrypt.conf; return 301 https://example.com$request_uri;
}
server {
listen 443 ssl http2;
server_name www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; return 301 https://example.com$request_uri;
}
server {
listen 443 ssl http2;
server_name example.com;
proxy_read_timeout 720s; proxy_connect_timeout 720s; proxy_send_timeout 720s; # Proxy headers 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; # SSL parameters ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem; include snippets/ssl.conf; include snippets/letsencrypt.conf; # log files access_log /var/log/nginx/odoo.access.log; error_log /var/log/nginx/odoo.error.log; # Handle / requests location / { proxy_redirect off; proxy_pass http://odoo; } # Cache static files location ~* /web/static/ { proxy_cache_valid 200 90m; proxy_buffering on; expires 864000; proxy_pass http://odoo; } # Gzip gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript; gzip on;
# sudo systemctl restart nginx
# vim /etc/odoo12.conf
Change proxy_mode to True
# sudo systemctl restart odoo12
At this point, your server is configured and you can access your Odoo instance at: https://example.com
Now, what if you have some subdomains and you want to link those subdomains to your specified databases ? Contact us to get help on that.