Skip to content
Maxime Chambreuil edited this page May 14, 2019 · 27 revisions

Welcome to the odoo-tutorial wiki!

apt update

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

# Webkit
wget https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb
wkhtmltopdf -V

# 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

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

# Download Odoo source code
cd /opt
git clone https://github.com/ursais/template-project -b 11.0 odoo
chown -R odoo:odoo odoo
apt install python3-virtualenv
su - odoo
cd /opt/odoo
vi .gitmodules # (replace [email protected]: by https://github.com/)
git submodule sync
git submodule update --init
git status

python3 -m virtualenv -p /usr/bin/python3 env
pip freeze
. env/bin/activate
pip freeze

pip install -r requirements.txt
cd odoo
python setup.py install
cd ..

# Start odoo
pip freeze
odoo
ls /home/odoo/.local/share/Odoo/

exit

# (as root)
mkdir /etc/odoo
vi /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

cp /etc/odoo/odoo.conf /etc/odoo/debug.conf
vi /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

# Start Odoo manually
su - odoo
cd /opt/odoo
. env/bin/activate
odoo -c /etc/odoo/debug.conf

# (as root) Start Odoo as a service
vi /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

# Configure Nginx
vi /etc/nginx/sites-available/odoo
## Odoo Backend ##
upstream odooerp {
    server 127.0.0.1:8069;
}

upstream odooim {
    server 127.0.0.1:8072;
}

## https site##
server {
    listen      443 default_server;
    server_name 68.183.161.193;
    root        /usr/share/nginx/html;
    index       index.html index.htm;
    client_max_body_size 	20M;

    # log files
    access_log  /var/log/nginx/odoo.access.log;
    error_log   /var/log/nginx/odoo.error.log;

    # ssl files
    ssl on;
    ssl_ciphers                 ALL:!ADH:!MD5:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM;
    ssl_protocols               TLSv1.2;
    ssl_prefer_server_ciphers   on;
    ssl_certificate             /etc/nginx/ssl/odoo.crt;
    ssl_certificate_key         /etc/nginx/ssl/odoo.key;

    # proxy buffers
    proxy_buffers 16 64k;
    proxy_buffer_size 128k;

    ## odoo proxypass with https ##
    location / {
        proxy_pass  http://odooerp;
        # force timeouts if the backend dies
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_redirect off;

        # set headers
        proxy_set_header    Host            $host;
        proxy_set_header    X-Real-IP       $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto https;
    }

    location /longpolling {
        proxy_pass  http://odooim;
    }

    # cache some static data in memory for 60mins
    location ~* /web/static/ {
        proxy_cache_valid 200 60m;
        proxy_buffering on;
        expires 864000;
        proxy_pass http://odooerp;
    }
}

## http redirects to https ##
server {
    listen      80;
    server_name 68.183.161.193;

    # Strict Transport Security
    add_header Strict-Transport-Security max-age=2592000;
    rewrite ^/.*$ https://$host$request_uri? permanent;
}

# 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
Clone this wiki locally