Installing Odoo 10 on the SUSE Platform


Introduction

My research into ERP systems over a couple of years led me to choose Odoo as a potential system for a new venture. The initial problem was that SUSE was not supported out of the box. As SUSE is my choice of platform for enterprise grade solution, I set about seeing how hard it would be to install Odoo on a SUSE platform. The experience was successful and these are my notes for others who may like to use SUSE for Odoo as well.

I chose OpenSUSE 42.2 as a leading edge stable platform. However, these notes shuld work at least as a guide for SUSE Enterprise 12, and slightly earlier version of OpenSUSE. I also note that my initial install was done with the help of some excellnt guides for Redhat and Debian available on the Internet.

SUSE Server Install



My installation included a virtual server under XEN, two 40G virtual drives formatted using EXT4. (You are on your own if you use btrfs the default). On my production server I moved the database onto my dedicated database server, so a single 50G partition should suit and this was the configuration I used for my test/dev/ instance of Odoo. Both instances run well with 4G of memory, however, more may be required for many users.

Installation instructions for SUSE are not covered here, except for a few special settings listed below.

I always use the KDE interface, but this is more user preference and I don't believe will impact the odoo implementation.

When selecting Application Packages, choose only the following

Plasma 5 Desktop

KDE Desktop Environment

Fonts

XWindow System

Base System

Enhanced Base System

AppArmor

Yast System Administration

Software Management

Misc Proprietary Packages

Base Development

Python Development

DO NOT Select Python3 development. Under details for Python Development, deselect Python3. Odoo requires Python 2.7

 

Enable SSH and open the SSH port on the firewall

Install your system and ensure you can login and have ssh access.

System Preparation

A number of additional tools will now be required. To start with install the packman and python repositories for your SUSE version.

Repositories

Repository Name: devel:languages:python

URL of the Repository: http://download.opensuse.org/repositories/devel:/languages:/python/openSUSE_Leap_42.2/

 

Repository Name: Packman Repository

URL of the Repository: http://packman.inode.at/suse/openSUSE_Leap_42.2/

Python

As a sanity check, run

 

python --version

It should return 2.7.X

In my case it is Python 2.7.12

If it is not 2.7 (eg is version 3) you have options to either run python is a self contained environment, point the python command the the python 2.7 executable or some other undefined solution. For this tutorial, I'm assuming python 2.7 is available on the main server and this is what odoo will use. We will come back to python requirements later.

Users

You will need a user to run the odoo application under. FOr this tutorial, I'm using the user odoo.

Create the user and group as follows. (Yast can also be used)

 

sudo useradd  --system --shell /bin/bash --home-dir /opt/odoo -U -m -c "odoo ERP User"  odoo

Directories

A config and Log directory are required and are created as follows. I was never able to get odoo to use the config file located in /etc/odoo instead relying upon the config in the odoo home directory. Until this is resolved the /etc/odoo directory is unused.

 

sudo mkdir /etc/odoo && mkdir /var/log/odoo/

Packages

A number of packages now need to be installed. Most can be installed from repositories setup during the install.

Postgresql


This is only required if the postgres server is to be run locally. Even though I have a separate dedicated database server, I'll choose to get the basic system running locally and then move the database.

zypper install postgresql postgresql-devel pgadmin3

postgresql94-devel is required if the DB is local or not.

Python and Other  libraries

Install the following libraries from the repositories. The rest of the dependencies will be installed using pip.

zypper install python-devel

sypper install python2-pip [LEAP 15]

zypper install python-lxml python-ldap python-dev git python-setuptools  libxslt1-dev  python-pip libxml2-devel libjpeg8-devel libxslt-devel libopenssl-devel

zypper install npm4

zypper install yast2-ca-management (Used for local server certificates if using SSL)

zypper install python-passlib

zypper install python-Werkzeug

zypper install python-dateutil

 

(There are a whole lot of Python components to install from the SUSE repository. They are not all listed here.)

Time to upgrade the version of pip.

pip install --upgrade pip

Cloning Odoo

The Odoo install we will be doing is done from source. Change to the odoo user (created above)

 

su - odoo

pwd

should return /opt/odoo

 

clone the Odoo Git repository (as the odoo user)

git clone --depth=1 --branch=10.0 https://github.com/odoo/odoo.git /opt/odoo/odoo

 

The step will take some time, about 15 minutes for a guide. Wait until it gets completed.

Installing Python Packages


Python is the core of Odoo. For proper functioning, it is necessary to get required python packages. copy and paste the command as the odoo user.

sudo chown odoo:odoo /opt/odoo/ -R && sudo chown odoo:odoo /var/log/odoo/ -R && cd /opt/odoo/odoo && sudo pip install --upgrade pip && sudo pip install -r requirements.txt

(for LEAP 15 use pip2, sudo chown odoo:odoo /opt/odoo/ -R && sudo chown odoo:odoo /var/log/odoo/ -R && cd /opt/odoo/odoo && sudo pip2 install --upgrade pip && sudo pip install -r requirements.txt )

Node and related packages to run Odoo Website

We will also require Nodejs and associated packages for Odoo website. Let's get it done by the following command.

Make sure you are connected as the odoo user in the home directory of odoo.

sudo npm install -g less less-plugin-clean-css -y

 

The /usr/bin/node may already exist. An associated error can be ignored.

 

wkhtltopdf library required to print reports from odoo
** Note LEAP 15 has build available on the software.opensuse.org site for direct install on LEAP 15 - No need to build **

To successfully get this to operate on SUSE, a build from source is required. As of the time of this tutorial, the version of wkhtltopdf is highly important if you wish to successfully integrate with Odoo version 10. Version 0.12.1 is required and is available from https://github.com/wkhtmltopdf/wkhtmltopdf/archive/0.12.1.tar.gz. An RPM version is also available to install directly. Check rpm.pbone, opensuse etc.

Down the wkhtmltox-0.12.1.tar.bz2 file and unpack into a directory away from your odoo install. On all my systems, I have a /var/Software directory for such source packages.

 

Make sure the following packages are installed using YAST

  libx11-dev, libxcursor-dev, libxext-dev, libxfixes-dev, libxft-dev, libxi-dev, libxrandr-dev and libxrender-dev?

cd /var/Software

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.1/wkhtmltox-0.12.1.tar.bz2

tar -xzf wkhtmltox-0.12.1.tar.bz2

cd wkhtmltox-0.12.1/
sudo scripts/build.py posix-local

 

This build takes quite some time, so be patient.

My build fails with the following lines.

tar: wkhtmltox-0.12.1: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
tar -c -v -f ../wkhtmltox-0.12.1_local-ebvl-015.tar wkhtmltox-0.12.1/
command failed: exit code 512

As it turns out the desired builds should exist. Copy the executables from /var/Software/wkhtmltox-0.12.1/static-build/posix-local/wkhtmltox-0.12.1/bin to /usr/bin

 

cp /var/Software/wkhtmltox-0.12.1/static-build/posix-local/wkhtmltox-0.12.1/bin/wkhtmltopdf /usr/bin
cp /var/Software/wkhtmltox-0.12.1/static-build/posix-local/wkhtmltox-0.12.1/bin/wkhtmltoimage /usr/bin

 

Optional installation of GeoIP database for user tracking on the website

If you are thinking of using Odoo to create your website, it is a good idea to get GeoIP. GeoIP locates the origin of the user and helps your business to understand the demographics better.

 

These can be installed directly from the SUSE Repositories

zypper install GeoIP

 

Create a User for PostgreSQL

To ensure that the database is setup properly fro the Odoo, we need to create a user for PostgreSQL.

At this point we have only installed postgresql. It probably isn't running. So we need to enable it and start it.

 

systemctl enable postgresql.service
rcpostgresql start

POST INSTALL

Let's do some sanity checks.

systemctl status postgresql.service

should show something like

 postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2017-01-19 09:34:45 AEST; 2min 11s ago
 Main PID: 17577 (postgres)
   CGroup: /system.slice/postgresql.service
           ├─17577 /usr/lib/postgresql94/bin/postgres -D /var/lib/pgsql/data
           ├─17578 postgres: logger process   
           ├─17580 postgres: checkpointer process   
           ├─17581 postgres: writer process   
           ├─17582 postgres: wal writer process   
           ├─17583 postgres: autovacuum launcher process   
           └─17584 postgres: stats collector process   

netstat -ntlp | grep 5432
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      17577/postgres      
tcp        0      0 ::1:5432                :::*                    LISTEN      17577/postgres 

 

Now we can add a user.

sudo su - postgres -c "createuser -s odoo"

Generating Odoo Config File

We need a config file to make Odoo work. To do so, copy and paste the below one command to the terminal.

sudo su - odoo -c "/opt/odoo/odoo/odoo-bin --addons-path=/opt/odoo/odoo/addons -s --stop-after-init"

 

You should see something like this

2017-01-18 23:51:25,394 17795 INFO ? odoo: Odoo version 10.0
2017-01-18 23:51:25,395 17795 INFO ? odoo: Using configuration file at /opt/odoo/.odoorc
2017-01-18 23:51:25,395 17795 INFO ? odoo: addons paths: ['/opt/odoo/.local/share/Odoo/addons/10.0', u'/opt/odoo/odoo/addons', '/opt/odoo/odoo/odoo/addons']
2017-01-18 23:51:25,395 17795 INFO ? odoo: database: default@default:default
2017-01-18 23:51:25,832 17795 INFO ? odoo.service.server: Initiating shutdown
2017-01-18 23:51:25,833 17795 INFO ? odoo.service.server: Hit CTRL-C again or send a second signal to force the shutdown.

Firewall Changes

If you used the default install, the firewall will be running and a port needs to be added to the allowed settings to enable access to odoo once it is running.

Using Yast2, edit the firewall settings and add port 8069. (Under Advanced TCP Port only)

Also add ports 80 and 443 for future web services using nginx.

Running Odoo as a Service

Before we can start Odoo, we need to change a couple of settings.

 

As the Odoo user, edit the .odoo.rc file and change the geoip_database to the following

geoip_database = /var/lib/GeoIP/GeoIPCity.dat

and the logfile location

logfile = /var/log/odoo/odoo.log                                                                                                                                                                                                                                              

 

The rest we will make after we have the basics running.

Odoo requires being served as service. Follow the instructions below.

 

As the root user, create a file in /etc/systemd/system called odoo.service

 

Paste the following into the file

[Unit]
Description=Odoo
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
User=odoo
Group=odoo
Type=simple
EnvironmentFile=/opt/odoo/.odoorc
WorkingDirectory=/opt/odoo
ExecStart=/opt/odoo/odoo/odoo-bin
#Restart=on-failure

[Install]
WantedBy=multi-user.target

Enable and start the service.

systemctl enable odoo.service

systemctl start odoo.service

 

Now for a sanity check

netstat -ntlp | grep 8069
tcp        0      0 0.0.0.0:8069            0.0.0.0:*               LISTEN      17954/python      

 

Now, all you need to do is go to the http://{IP_ADDRESS}:8069 and try out the installation.


NGINX

Installing NGINX

zypper install nginx

mkdir /etc/nginx/conf.d

mkdir /etc/nginx/vhosts.d

 

Start nginx and enable it to be started at boot time:

systemctl start nginx
systemctl enable nginx

Nginx is started now, but if you try to access it through the web browser, you will get a 403 forbidden error. This error occurs because there is no standard index document in the web root folder. To solve this problem, create a new index html in the root web directory "/srv/www/htdocs". Go to the directory and create the index.html file:


Configure NGINX for Odoo

Get your machine’s IP Address by following command

 

ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'

Create a configuration for Odoo, DONOT FORGET TO REPLACE $IPADR value with your IP Address.

vi /etc/nginx/conf.d/odoo

 

Put the following content in the file.

 

    upstream odooweb {

    server 0.0.0.0:8069 weight=1 fail_timeout=300s;

    }

    upstream odooweb-im {

     server 0.0.0.0:8072 weight=1 fail_timeout=300s;

    }

    server {

    # server port and name

    listen 80;

    server_name $IPADR;

    # Specifies the maximum accepted body size of a client request,

    # as indicated by the request header Content-Length.

    client_max_body_size 200m;

    #log files

    access_log /var/log/nginx/odoo-access.log;

    error_log /var/log/nginx/odoo-error.log;

    proxy_connect_timeout 600;

    proxy_send_timeout 600;

    proxy_read_timeout 600;

    send_timeout 600;

    keepalive_timeout 600;

    gzip on;

    gzip_disable "msie6";

    gzip_vary on;

    gzip_proxied any;

    gzip_comp_level 6;

    gzip_buffers 16 8k;

    gzip_http_version 1.1;

    gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss application/rss+xml text/javascript image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype image/bmp image/png image/gif image/jpeg image/jpg;

    # increase proxy buffer to handle some odoo web requests

    proxy_buffers 16 64k;

    proxy_buffer_size 128k;

    location / {

    proxy_pass http://odooweb;

    # force timeouts if the backend dies proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;

    # set headers

    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 http;

    # by default, do not forward anything

    proxy_redirect off; }

    location /longpolling {

    proxy_pass http://odooweb-im; }

    # cache some static data in memory for 60mins.

    # under heavy load this should relieve stress on the odoo web interface a bit.

    location ~* /web/static/ {

    proxy_cache_valid 200 60m;

    proxy_buffering on;

    expires 864000;

    proxy_pass http://odooweb;

    }

    }

Create a Virtual Host

edit a vhost file in /etc/nginx/vhosts.d called odoo.conf

Please note this configuration include an SSL example. You will need to either purchase an SSL certificate or use your server certificate and copy the certificate files into /etc/nginx/ssl

To use local server certificates install yast2-auth-server

 

zypper install yast2-auth-server

 

Use the Yast utilities to create and export a server certificate.

 

Paste the following into it.

server {
        listen       80;
        server_name  $IPADDR;    #Domain Name
        rewrite ^ https://$http_host$request_uri? permanent;    # force redirect http to https
    }
    server {
        listen 443;
        ssl on;
        ssl_certificate /etc/nginx/ssl/cacert.pem;        # path to your cacert.pem
        ssl_certificate_key /etc/nginx/ssl/privkey.pem;    # path to your privkey.pem
        server_name $IPADDR;                    #Domain Name
        proxy_set_header X-Forwarded-For $remote_addr;

        add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
        server_tokens off;

        location / {
#            root   /srv/www/htdocs/;
#            index  index.html index.htm;
            proxy_pass http://127.0.0.1:8069;
            proxy_redirect off;
            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 $scheme;
            }

        }

 

At this point you should be able to access Odoo directly using the address of your server. http://

If you configured SSL, you wil be redirected to https:///web/database/selector

 

Odoo is now ready to setup. Follow the Odoo documentation to continue from this point.

 

Remote Database

As I have a separate database server and I already have a test database, I will simply edit the odoo config file to point it to this database.

As my test database is a copy of my live database currently, I need to setup a new user in postgresql under which the test database is to be run.

 

In order to connect to an external database the following line in ~/.odoorc need to be changed.

db_host =
db_maxconn = 64
db_name =
db_password = <db_userpassword>
db_port = 5432
db_template = template1
db_user = <db_user>