Home - smangukiya/odoo-tutorial-1 GitHub Wiki

Welcome to the odoo-tutorial wiki!

#Step1: Update the libs
apt update

#Step2: Install the needed libs
apt install backup-manager certbot git libgeoip-dev libjpeg-dev libldap2-dev libsasl2-dev libxml2-dev libxslt1-dev nginx node-less npm poppler-utils postfix postgresql postgresql-server-dev-10 python-certbot-nginx python3-dev python-pip python-psycopg2 software-properties-common zlib1g-dev fontconfig xfonts-75dpi xfonts-base

#Step3: Install Webkit
wget https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb (old)
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb (new)
dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb
wkhtmltopdf -V

#Step4: Add PostgreSQL user for Odoo
su - postgres
createuser -s -d odoo
psql
\password odoo
pass: odoo
\q
psql -h localhost -U odoo template1
\q
exit

#Step5: (as root) Add system user
adduser odoo
pass: odoo

#Step6: Download Odoo source code
cd /opt
git clone https://github.com/name/template-proj -b 11.0 odoo

#Step7: Change the ownership to Odoo user and sync git repo
chown -R odoo:odoo odoo
su - odoo
cd /opt/odoo
vi .gitmodules # (replace [email protected]: by https://github.com/)
git submodule sync
git submodule update --init
git status


#Step8: Install virtual environment
apt install python3-virtualenv

#Step9: Activate the virtual environment and install all the required libs for Odoo with Odoo user
python3 -m virtualenv -p /usr/bin/python3 env
pip freeze
. env/bin/activate
pip freeze
pip install -r requirements.txt

#Step10: Execute/Install Odoo setup file
cd odoo
python setup.py install
cd ..

#Step11: Get Odoo filestore path
# Start odoo
pip freeze
odoo
ls /home/odoo/.local/share/Odoo/
exit

#Step12: Define Odoo config file
# (as root)
mkdir /etc/odoo
vim /etc/odoo/odoo.conf
[options]
admin_passwd = admin
addons_path = /opt/odoo/src/enterprise,/opt/odoo/odoo/addons,/opt/odoo/src/custom-addons
db_host = localhost
db_port = 5432
db_user = odoo
db_password = odoo
log_level = info
logfile = /var/log/odoo/odoo.log
max_cron_threads = 1
proxy_mode = True
# workers =  (2 x # of proc + 1)
workers = 3
xmlrpc_interface = 127.0.0.1

#Step13: Copy config file as debug file and remove log parameter and set ownership to Odoo user
cp /etc/odoo/odoo.conf /etc/odoo/debug.conf
vim /etc/odoo/debug.conf # comment the logfile to get the logs in stdout
mkdir /var/log/odoo
chown -R odoo:odoo /etc/odoo
chown -R odoo:odoo /var/log/odoo

#Step14: Start odoo manually using debug file
su - odoo
cd /opt/odoo
. env/bin/activate
odoo -c /etc/odoo/debug.conf


#Step15: (as root) Start Odoo as a service
vim /etc/systemd/system/odoo.service
[Unit]
Description=Odoo

[Service]
User=odoo
Group=odoo
WorkingDirectory=/opt/odoo
ExecStart=/opt/odoo/env/bin/odoo -c /etc/odoo/odoo.conf
Restart=always

[Install]
WantedBy=multi-user.target

systemctl daemon-reload
service odoo start
tail -f /var/log/odoo/odoo.log
systemctl status odoo
systemctl enable odoo
systemctl status odoo

#Step16: Configure Nginx
vim /etc/nginx/sites-available/odoo
server {
   listen 80;
   server_name                167.71.187.36;
   return 301                 https://$host$request_uri; # managed by Certbot SSL certificate
}

server {
    listen 443 ssl;
    ssl on;
    ssl_certificate             /etc/nginx/ssl/odoo.crt;
    ssl_certificate_key         /etc/nginx/ssl/odoo.key;
    server_name 167.71.187.36;
    keepalive_timeout 60;

    proxy_buffering off;
    proxy_redirect http:// https://;
    proxy_connect_timeout 60000;
    proxy_send_timeout 60000;
    proxy_read_timeout 60000;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;

    proxy_max_temp_file_size    1924m;
    send_timeout                300;
    client_max_body_size        500M;
    client_body_timeout         300;

    # limit ciphers
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";  # This will not work on IE6/WinXP or older browsers
    ssl_protocols TLSv1.2;
    ssl_prefer_server_ciphers on;

    ssl_session_cache builtin:1000 shared:SSL:10m;
    ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
    ssl_session_tickets off; # Requires nginx >= 1.5.9

    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-Content-Type-Options nosniff;

    access_log            /var/log/nginx/access.log;
    error_log             /var/log/nginx/error.log;

    location / {
      proxy_pass          http://localhost:8069;
    }
    location /longpolling {
        proxy_pass http://127.0.0.1:8072;
    }

    location /web/static/ {
        proxy_cache_valid 200 60m;
        proxy_buffering on;
        expires 864000;
        proxy_pass http://127.0.0.1:8069;
    }

}



#Step17: Generate the SSL certificate
mkdir /etc/nginx/ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
        -subj "/C=US/ST=CA/L=Los Angeles/O=IT/CN=68.183.161.193" \
        -keyout /etc/nginx/ssl/odoo.key \
        -out /etc/nginx/ssl/odoo.crt

cd /etc/nginx/sites-enabled
ln -s ../sites-available/odoo .
nginx -t
service nginx restart