Project

General

Profile

Support #722

Updated by Daniel Curtis over 8 years ago

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

 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>  

 * Edit the Odoo user .login_conf script: 
 <pre> 
 vi /home/odoo/.login_conf 
 </pre> 
 #* And add the following lines: 
 <pre> 
 me:\ 
         :charset=UTF-8:\ 
         :lang=en_US.UTF-8:\ 
         :setenv=LC_COLLATE=C: 
 </pre> 

 * Install the dependencies using pkgng: 
 <pre> 
 pkg install py27-Jinja2 py27-libxml2 py27-xlwt py27-pytz py27-mx-base py27-psycopg2 py27-chart py27-pydot py27-libxslt py27-lxml py27-yaml py27-mako py27-dateutil py27-reportlab py27-werkzeug py27-vobject py27-vatnumber py27-unittest2 py27-simplejson py27-requests py27-qrcode py27-usb py27-python-openid py27-openid py27-ldap py27-serial py27-pdf py27-pyparsing py27-psycogreen py27-psycopg2 py27-psutil py27-pillow py27-passlib py27-mock py27-gevent py27-feedparser py27-decorator py27-docutils wkhtmltopdf node npm openldap-sasl-client 
 </pre> 

 * Install less nodejs package: 
 <pre> 
 npm install -g less less-plugin-clean-css 
 </pre> 

 h2. Install PostgreSQL 9.4 

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

 * Enable PostgreSQL at boot: 
 <pre> 
 echo 'postgresql_enable="YES"' >> /etc/rc.conf 
 </pre> 

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

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

 * Edit the postgres config file: 
 <pre> 
 vi /usr/local/pgsql/data/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 pgsql 
 psql -d template1 
 </pre> 
 #* Create the *odoouser* user and *odoodb* database: 
 <pre> 
 CREATE USER odoouser WITH PASSWORD 'SuperSecretPassword'; 

 ALTER USER odoouser 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 9 

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

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

 * Install any missing dependencies: 
 <pre> 
 cd odoo 
 setenv CPPFLAGS "-I /usr/local/include -I /usr/local/include/sasl" 
 pip install -r requirements.txt 
 </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> 
 mkdir /var/log/odoo 
 touch /var/log/odoo/odoo-server.log 
 chmod 755 /var/log/odoo 
 chown -R odoo:wheel /var/log/odoo 
 </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/odoo-server.log 
 log_level = error  
 </pre> 

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

 * Edit the openerp-server script: 
 <pre> 
 vi /usr/local/www/odoo/openerp-server 
 </pre> 
 #* And change the env from python to python2, and set the default encoding to utf8 
 <pre> 
 #!/usr/bin/env python2 
 import openerp 
 import sys 
 reload(sys) 
 sys.setdefaultencoding('utf8') 

 if __name__ == "__main__": 
     openerp.cli.main() 
 </pre> 

 * Now test run the Odoo server: 
 <pre> 
 su - odoo 
 cd odoo 
 ./openerp-server --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 
 * https://www.getopenerp.com/install-odoo-9-on-ubuntu/

Back