Project

General

Profile

Support #954

Updated by Daniel Curtis about 4 years ago

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

 This is a guide on how I installed Odoo 9 on FreeBSD 10. 

 h2. Prepare the Environment 

 * Make sure the system is up to date: 
 <pre> 
 pkg update && pkg upgrade 
 </pre> 

 * Add the Odoo user 
 <pre> 
 pw add user -n odoo -m -s /bin/sh -c "Odoo" 
 </pre>  

 * Install the dependencies using pkgng: 
 <pre> 
 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 
 </pre> 

 h2. Install PostgreSQL 9.6 

 * Install PostgreSQL: 
 <pre> 
 pkg install postgresql96-{server,client} 
 </pre> 

 * Enable PostgreSQL at boot: 
 <pre> 
 sysrc 'postgresql_enable=YES' 
 </pre> 

 * Initialize the database: 
 <pre> 
 service postgresql initdb 
 </pre> 

 * Start PostgreSQL: 
 <pre> 
 service postgresql start 
 </pre> 

 * Edit the postgres config file: 
 <pre> 
 vi /var/db/postgres/data96/postgresql.conf 
 </pre> 
 #* And modify the following: 
 <pre> 
 listen_addresses = '*' 
 </pre> 

 * Edit the pg_hba config file: 
 <pre> 
 vi /usr/local/etc/pgsql/data/pg_hba.conf 
 </pre> 
 #* And modify the following: 
 <pre> 
 # TYPE    DATABASE      USER          CIDR-ADDRESS            METHOD only 

 # Local connections 
 local     all           all                                 trust 

 # IPv4 local connections: 
 host      all           all           127.0.0.1/32            trust 

 # IPv6 local connections: 
 host      all           all           ::1/128                 trust 

 # IPv4 connections: 
 host      all           all           192.168.10.0/24         md5 
 </pre> 

 * Restart postgresql: 
 <pre> 
 service postgresql restart 
 </pre> 

 h2. Create a new user and database 

 * Switch to the pgsql user and enter into the psql prompt: 
 <pre> 
 su postgres 
 psql -d template1 
 </pre> 
 #* Create the *odoouser* user and *odoodb* database: 
 <pre> 
 CREATE USER odoouser WITH PASSWORD 'SuperSecretPassword' CREATEDB; 

 CREATE DATABASE odoodb OWNER odoouser ENCODING 'UTF8'; 

 GRANT ALL PRIVILEGES ON DATABASE "odoodb" to odoouser; 
 </pre> 

 * Exit from the postgres user 
 <pre> 
 \q 
 exit 
 </pre> 

 * Test the connection on a remote host: 
 <pre> 
 psql -h pg.example.com -U odoouser -W odoodb 
 </pre> 

 h2. Install Odoo 14 

 * Switch to the Odoo user folder: 
 <pre> 
 cd /usr/local/www 
 </pre> 

 * Clone the latest Odoo 14 code from GitHub: 
 <pre> 
 git clone https://github.com/odoo/odoo --depth 1 --branch 14.0 --single-branch 
 chown -R odoo:odoo odoo 
 </pre> 

 * Install any missing dependencies: 
 <pre> 
 su - odoo 
 cd /usr/local/www/odoo 
 env CPPFLAGS="-I /usr/local/include -I /usr/local/include/sasl" pip install -r requirements.txt 
 exit 
 </pre> 

 * Create a folder for custom addons: 
 <pre> 
 mkdir -p /usr/local/www/odoo/custom/addons 
 chown -R odoo:odoo /usr/local/www/odoo/custom 
 </pre> 

 * Create the odoo log folder: 
 <pre> 
 touch /var/log/odoo.log 
 chmod 644 /var/log/odoo.log 
 chown -R odoo:wheel /var/log/odoo.log 
 </pre> 

 * Create the odoo pid folder:  
 <pre> 
 mkdir /var/run/odoo  
 chown odoo /var/run/odoo 
 </pre> 

 * Create the Odoo config: 
 <pre> 
 vi /usr/local/etc/odoo.conf 
 </pre> 
 #* And Modify the following parameters: 
 <pre> 
 [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  
 </pre> 

 * Make the odoo config owner the odoo user: 
 <pre> 
 chown odoo /usr/local/etc/odoo.conf 
 </pre> 

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

 * Now test run the Odoo server: 
 <pre> 
 ./odoo-bin --config=/usr/local/etc/odoo.conf 
 </pre> 

 * Open a web browser and go to http://odoo.example.com:8069 and go to *manage databases*. 
 * *Set a new master password*, the default master password is *admin* 
 * Next click *Create database*; enter the master password, new database name, and the admin password. 
 * Go back to http://odoo.example.com:8069 and log in, the default username is *admin* and password is *admin* 

 h2. Odoo Init Script 

 * Create a new rc script for odoo: 
 <pre> 
 vi /usr/local/etc/rc.d/odoo 
 </pre> 
 #* And add the following: 
 <pre> 
 #!/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"  
 </pre>  

 * Make the script executable: 
 <pre> 
 chmod +x /usr/local/etc/rc.d/odoo 
 </pre> 

 * Start and enable odoo at boot: 
 <pre> 
 echo 'odoo_enable="YES"' >> /etc/rc.conf 
 service odoo start 
 </pre> 

 h2. Resources 

 * https://github.com/odoo/odoo

Back