How to Set Up an Odoo 15.0 Development Environment on Ubuntu 22.04 Jammy Jellyfish with PostgreSQL, wkhtmltopdf, Node.js, and Nginx Reverse Proxy?

This tutorial aims to guide new developers on how to set up an Odoo 15.0 development environment on Ubuntu 22.04 Jammy Jellyfish. By following the instructions, users can quickly gain an understanding of the various components required for Odoo development. The tutorial covers topics such as using Python virtualenv, installing PostgreSQL server, Python3.8, wkhtmltopdf, node.js and nvm, and Nginx server installation and configuration as an Odoo reverse proxy.

To install Odoo, start by updating the packages, adding the deadsnakes repository for Python 3.8, and installing dependencies for pip to compile source Python packages. Then shallow clone the Odoo CE to save space, create and activate a Python virtual environment, install Python libraries, and verify it works.

# update packages
sudo apt update && sudo apt upgrade -y
# add deadsnakes repo because we need python 3.8
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa -y
# install dependencies for pip to compile source python packages
sudo apt install python3.8 python3.8-dev python3.8-distutils python3.8-lib2to3 python3-virtualenv libpq-dev libldap2-dev libssl-dev libsasl2-dev libjs-underscore
fonts-dejavu-core fonts-freefont-ttf fonts-freefont-otf fonts-noto-core fonts-inconsolata fonts-font-awesome fonts-roboto-unhinted gsfonts p7zip-full -y
# shallow clone Odoo CE to save space
git clone --branch 15.0 --depth=1 https://github.com/odoo/odoo.git ~/git/odoo/15.0
# create and activate python virtual environment
virtualenv --python=python3.8 ~/envs/15.0
source ~/envs/15.0/bin/activate
# install python libs
pip install -r ~/git/odoo/15.0/requirements.txt
# make sure it works
~/git/odoo/15.0/odoo-bin --version


To install PostgreSQL server, install it with sudo apt install postgresql -y, create a superuser for the nix user, and create a new database with test data and CRM app.

sudo apt install postgresql -y
# create a super user for your nix user to connect using unix sockets
sudo -H -u postgres -- createuser --superuser $USER
# let's create a new db with test data and CRM app
~/git/odoo/15.0/odoo-bin -d v15_test --stop-after-init --no-http -i crm


To install wkhtmltopdf, which is responsible for creating reports by converting HTML to PDF, first download the wkhtmltox package and extract it, and then install it with dpkg and apt-get.

wget https://github.com/wkhtmltopdf/packaging/files/8632951/wkhtmltox_0.12.5-1.jammy_amd64.zip
7z x wkhtmltox_0.12.5-1.jammy_amd64.zip
sudo dpkg -i wkhtmltox_0.12.5-1.jammy_amd64.deb
sudo apt install --fix-broken


Odoo uses node.js for processing CSS, so you need to install node.js and node-less by downloading the NVM installation script, installing NVM, and then installing Node.js 14 with NVM. Finally, you need to install some necessary node modules.

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
nvm install 14
npm install -g less rtlcss rtl-detect clean-css postcss-ltr-rtl-detect


To install Nginx, run the command sudo apt install nginx. Then, replace the default file in the /etc/nginx/sites-available/ directory with the configuration provided in the tutorial. The configuration includes settings for the Odoo server, proxy buffer size, client maximum body size, and gzip compression. It also includes settings for proxying requests and for handling long polling requests.

sudo apt install nginx
upstream odoo_srv {
    server 127.0.0.1:8069 weight=1 fail_timeout=0;
}
upstream odoo_long {
    server 127.0.0.1:8072 weight=1 fail_timeout=0;
}
server {
    listen 80 default_server;
    server_name www.odoo.local;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    proxy_buffers 16 64k;
    proxy_buffer_size 128k;
    client_max_body_size 4M;
    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_http_version 1.1;
    gzip_min_length 256;
    gzip_types
        text/css
        text/javascript
        text/xml
        text/plain
        image/bmp
        image/gif
        image/jpeg
        image/jpg
        image/png
        image/svg+xml
        image/x-icon
        application/javascript
        application/json
        application/rss+xml
        application/vnd.ms-fontobject
        application/x-font-ttf
        application/x-javascript
        application/xml
        application/xml+rss;
    location ~* ^/([^/]+/static/|web/(css|js)/|web/image/|web/content/|website/image/) {
        proxy_cache_valid 200 60m;
        proxy_buffering on;
        expires 30d;
        proxy_pass http://odoo_srv;
    }
    location / {
        proxy_pass http://odoo_srv;
        proxy_connect_timeout 360s;
        proxy_send_timeout 360s;
        proxy_read_timeout 360s;
        proxy_set_header Host $host;
        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;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
        proxy_redirect off;
    }
    location /longpolling {
        proxy_pass http://odoo_long;
        proxy_set_header Host $host;
        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;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
        proxy_redirect off;
    }
}
sudo nginx -t && sudo systemctl reload nginx.service
# let's run the server and text on port 80
~/git/odoo/15.0/odoo-bin -d v15_test --db-filter ^v15_test$ --workers 3


By following these steps, new developers can set up an Odoo 15.0 development environment on Ubuntu 22.04 Jammy Jellyfish, allowing them to start developing for Odoo quickly and efficiently.


Share this post
Archive
Sign in to leave a comment
How much to make a simple e-commerce WeChat Mini Program?