Project

General

Profile

Support #955

Updated by Daniel Curtis over 3 years ago

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

 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-pyserial py37-setuptools python37 gettext-runtime indexinfo gettext-tools libtextstyle libffi pkgconf readline wkhtmltopdf binutils gmake gmp texinfo p5-Text-Unidecode perl5 p5-Locale-libintl libiconv help2man p5-Locale-gettext p5-Unicode-EastAsianWidth mpfr jpeg-turbo cmake libarchive liblz4 meson ninja lzo2 expat jsoncpp libuv autoconf autoconf-wrapper m4 automake libtool curl libnghttp2 rhash py37-sphinx py37-Jinja2 py37-babel py37-pytz py37-markupsafe py37-packaging py37-pyparsing py37-six py37-imagesize py37-alabaster py37-docutils py37-pygments py37-snowballstemmer py37-pystemmer py37-cython py37-sphinxcontrib-applehelp py37-sphinxcontrib-devhelp py37-sphinxcontrib-htmlhelp py37-sphinxcontrib-jsmath py37-sphinxcontrib-qthelp py37-sphinxcontrib-serializinghtml py37-requests py37-idna py37-urllib3 py37-pysocks py37-certifi py37-cryptography py37-cffi py37-pycparser py37-openssl py37-chardet nasm png gcc8 mpc freetype2 fontconfig gperf webfonts cabextract mkfontscale xorg-macros libfontenc xorgproto libX11 libxcb libpthread-stubs libXau libXdmcp xcb-proto libxml2 xtrans libXext libXrender postgresql12-client py37-psycopg2 py37-vobject py37-dateutil py37-setuptools_scm py37-toml libevent    py37-decorator py37-gevent libev py37-greenlet py37-zope.event py37-zope.interface c-ares py37-lxml libxslt libgcrypt libgpg-error py37-mock py37-num2words py37-polib py37-pyusb py37-ebaysdk py37-ofxparse py37-coverage py37-nose py37-beautifulsoup448 py37-soupsieve py37-vatnumber py37-stdnum py37-pillow py37-olefile lcms2 tiff jbigkit openjpeg webp giflib tcl86 py37-tkinter tk86 libXft libXScrnSaver py37-pydot graphviz bison glib pcre docbook-xml xmlcatmgr xmlcharent docbook-xsl docbook docbook-sgml iso8879 sdocbook-xml libltdl cairo mesa-libs zstd libunwind llvm10 libedit swig lua52    py37-recommonmark py37-CommonMark py37-future libdrm libpciaccess pciids wayland libepoll-shim wayland-protocols    py37-mako py37-beaker libXdamage libXfixes libXrandr libXxf86vm libxshmfence pixman ghostscript9-agpl-base libidn jbig2dec poppler-data cups dbus minixmlto html2text libICE libSM avahi-app gdbm dbus-glib gobject-introspection libdaemon gnome_subr intltool p5-XML-Parser libpaper gnutls libunistring libidn2 libtasn1 nettle p11-kit bash-completion bash gtk-doc highlight boost-libs boost-jam icu itstool py37-libxml2 trousers tpm-emulator groff gsfonts psutils uchardet libXaw libXmu libXt libXpm pango fribidi harfbuzz graphite2 encodings font-util xorg-fonts-truetype dejavu font-bh-ttf bdftopcf font-misc-ethiopic font-misc-meltho openldap-client py37-ldap py37-pyasn1-modules py37-pyasn1 py37-zeep py37-appdirs py37-attrs py37-cached-property py37-defusedxml py37-isodate py37-xmlsec py37-pkgconfig xmlsec1 nspr nss sqlite3 py37-aiohttp py37-async_timeout py37-multidict py37-yarl py37-typing-extensions py37-requests-toolbelt py37-sphinx_rtd_theme py37-tornado4 py37-pdf2 py37-reportlab adobe-cmaps cyrus-sasl py37-passlib py37-psutil py37-feedparser py37-html2text py37-qrcode py37-xlrd py37-xlsxwriter py37-xlwt py37-libsass libsass py37-secure-cookie py37-werkzeug git portmaster 
 </pre> 

 * Add the Odoo user Update ports tree: 
 <pre> 
 pw add user -n odoo -m -s /bin/sh -c "Odoo" portsnap fetch extract 
 </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> 
 # 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 13 12 

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

 * Clone the latest Odoo 13 12 code from GitHub: 
 <pre> 
 git clone https://github.com/odoo/odoo --depth 1 --branch 13.0 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> 

 *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: 
 <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* 
 * Go back to http://odoo.example.com:8069 and log in, the default username is *admin* and password is *admin* 

 h3. 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