Project

General

Profile

Support #954

Install Odoo 14 on FreeBSD 12.2

Added by Daniel Curtis about 4 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Accounting Server
Target version:
Start date:
12/08/2020
Due date:
% Done:

100%

Estimated time:

Description

This is a guide on setting up Odoo 14 on FreeBSD 12.2-RELEASE.

Prepare the Environment

  • Make sure the system is up to date:
    pkg update && pkg upgrade
    
  • Add the Odoo user
    pw add user -n odoo -m -s /bin/sh -c "Odoo" 
    
  • Install the dependencies using pkgng:
    pkg install py37-pip py37-Jinja2 py37-libxml2 py37-xlwt py37-pytz py37-psycopg2 py37-pydot py37-lxml py37-yaml py37-mako py37-dateutil py37-reportlab py37-werkzeug py37-vobject py37-vatnumber py37-unittest2 py37-simplejson py37-requests py37-qrcode py37-pyusb py37-python-openid py37-ldap py37-pdf py37-pyparsing py37-psycogreen py37-psycopg2 py37-psutil py37-pillow py37-passlib py37-mock py37-gevent py37-feedparser py37-decorator py37-docutils git wkhtmltopdf node npm openldap-sasl-client
    

Install PostgreSQL 9.6

  • Install PostgreSQL:
    pkg install postgresql96-{server,client}
    
  • Enable PostgreSQL at boot:
    sysrc 'postgresql_enable=YES'
    
  • Initialize the database:
    service postgresql initdb
    
  • Start PostgreSQL:
    service postgresql start
    
  • Edit the postgres config file:
    vi /var/db/postgres/data96/postgresql.conf
    
    • And modify the following:
      listen_addresses = '*'
      
  • Edit the pg_hba config file:
    vi /usr/local/etc/pgsql/data/pg_hba.conf
    
    • And modify the following:
      # IPv4 connections:
      host    all         all         192.168.10.0/24       md5
      
  • Restart postgresql:
    service postgresql restart
    

Create a new user and database

  • Switch to the pgsql user and enter into the psql prompt:
    su postgres
    psql -d template1
    
    • Create the odoouser user and odoodb database:
      CREATE USER odoouser WITH PASSWORD 'SuperSecretPassword' CREATEDB;
      
      CREATE DATABASE odoodb OWNER odoouser ENCODING 'UTF8';
      
      GRANT ALL PRIVILEGES ON DATABASE "odoodb" to odoouser;
      
  • Exit from the postgres user
    \q
    exit
    
  • Test the connection on a remote host:
    psql -h pg.example.com -U odoouser -W odoodb
    

Install Odoo 14

  • Switch to the Odoo user folder:
    cd /usr/local/www
    
  • Clone the latest Odoo 14 code from GitHub:
    git clone https://github.com/odoo/odoo --depth 1 --branch 14.0 --single-branch
    chown -R odoo:odoo odoo
    
  • Install any missing dependencies:
    su - odoo
    cd /usr/local/www/odoo
    env CPPFLAGS="-I /usr/local/include -I /usr/local/include/sasl" pip install -r requirements.txt
    exit
    
  • Create a folder for custom addons:
    mkdir -p /usr/local/www/odoo/custom/addons
    chown -R odoo:odoo /usr/local/www/odoo/custom
    
  • Create the odoo log folder:
    touch /var/log/odoo.log
    chmod 644 /var/log/odoo.log
    chown -R odoo:wheel /var/log/odoo.log
    
  • Create the odoo pid folder:
    mkdir /var/run/odoo 
    chown odoo /var/run/odoo
    
  • Create the Odoo config:
    vi /usr/local/etc/odoo.conf
    
    • And Modify the following parameters:
      [options]
      ; This is the password that allows database operations:
      ; admin_passwd = admin
      db_host = localhost
      db_port = 5432
      database = odoodb
      db_user = odoouser
      db_password = SuperSecretPassword
      addons_path = /usr/local/www/odoo/addons,/usr/local/www/odoo/custom/addons
      logfile = /var/log/odoo.log
      log_level = error 
      
  • Make the odoo config owner the odoo user:
    chown odoo /usr/local/etc/odoo.conf
    

NOTE: I had to change the /usr/bin/env python3 to /usr/bin/env python3.7 in odoo-bin for it to work correctly.

  • Initialize the database:
    su - odoo
    cd /usr/local/www/odoo
    ./odoo-bin -i base -d odoodb --stop-after-init --db_host=localhost -r odoouser -w SuperSecretPassword
    
  • Now test run the Odoo server:
    ./odoo-bin --config=/usr/local/etc/odoo.conf
    

Odoo Init Script

  • Create a new rc script for odoo:
    vi /usr/local/etc/rc.d/odoo
    
    • And add the following:
      #!/bin/sh
      #
      # PROVIDE: odoo
      # REQUIRE: postgresql LOGIN
      #
      # Add the following lines to /etc/rc.conf to enable odoo server
      #
      #
      # odoo_enable (bool): Set to "NO" by default,
      #                         Set it to "YES" to enable odoo server
      #
      # odoo_config (str):  The path to the odoo server configuration file
      #                         (defaults to /usr/local/etc/odoo.conf)
      
      . /etc/rc.subr
      
      name=odoo
      command=/usr/local/www/odoo/openerp-server
      rcvar=odoo_enable
      
      load_rc_config $name
      
      odoo_enable="${odoo_enable-"NO"}" 
      odoo_config="${odoo_config-"/usr/local/etc/odoo.conf"}" 
      odoo_user="${odoo_user-"odoo"}" 
      odoo_pidfile="${odoo_pidfile:-"/var/run/odoo/odoo.pid"}" 
      odoo_flags="${odoo:-"--config=${odoo_config} --pidfile=${odoo_pidfile} "}" 
      
      # /etc/rc.subr use $pidfile (not ${name}_pidfile)
      pidfile="${odoo_pidfile}" 
      
      required_files="${odoo_config}" 
      
      start_cmd="su - ${odoo_user} -c '${command} ${odoo_flags}' &" 
      stop_cmd="${name}_stop" 
      status_cmd="${name}_status" 
      getval_cmd="${name}_getval" 
      
      odoo_stop()
      {
          odoo_pid=$(pgrep -f "openerp-server")
      
          echo "Stopping ${name}." 
          kill -s TERM "$(cat "${odoo_pidfile}")" 
      
          echo "Stopping ${name}." 
          kill -s TERM "${openerpd_pid}" 
      }
      
      odoo_status()
      {
          # Try its best to find the service's status
          if [ -f "${odoo_pidfile}" ]
          then
              odoo_pid="$(cat "${odoo_pidfile}")" 
          fi
      
          if [ -z "${odoo_pid}" ]
          then
          odoo_pid=$(pgrep -f "openerp-server")
          [ -n "${odoo_pid}" ] && echo "${odoo_pid}" > "${odoo_pidfile}" 
          fi
      
          if [ -n "${odoo_pid}" ]
          then
              echo "${name} running with pid: $odoo_pid" 
          else
              echo "${name} not running? (pid not found)" 
          fi
      }
      
      command_args=" >/dev/null 2>&1 &" 
      
      load_rc_config $name
      run_rc_command "$1" 
      
  • Make the script executable:
    chmod +x /usr/local/etc/rc.d/odoo
    
  • Start and enable odoo at boot:
    echo 'odoo_enable="YES"' >> /etc/rc.conf
    service odoo start
    

Resources

#1

Updated by Daniel Curtis about 4 years ago

  • Tracker changed from Bug to Support
  • Status changed from New to In Progress
#2

Updated by Daniel Curtis about 4 years ago

  • Description updated (diff)
  • Category set to Accounting Server
  • Assignee set to Daniel Curtis
  • Target version set to FreeBSD 12
  • % Done changed from 0 to 50
#3

Updated by Daniel Curtis about 4 years ago

  • Description updated (diff)
#4

Updated by Daniel Curtis about 4 years ago

  • Description updated (diff)
  • Status changed from In Progress to Resolved
  • % Done changed from 50 to 100
#5

Updated by Daniel Curtis almost 3 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF