Support #955
Updated by Daniel Curtis about 4 years ago
This is a guide on setting up Odoo 13 from source on FreeBSD 12.2-RELEASE. h2. Prepare the Environment * Make sure the system is up to date: <pre> pkg update && pkg upgrade </pre> * Install the dependencies using pkgng: <pre> pkg install python37 py37-pip 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 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 libevent libev c-ares libxslt libgcrypt libgpg-error lcms2 tiff jbigkit openjpeg webp giflib tcl86 tk86 libXft libXScrnSaver 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 libdrm libpciaccess pciids wayland libepoll-shim wayland-protocols 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 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 xmlsec1 nspr nss sqlite3 adobe-cmaps cyrus-sasl libsass git </pre> * Add the Odoo user <pre> pw add user -n odoo -m -s /usr/local/bin/bash -c "Odoo" </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 * Switch to the @/usr/local/www@ folder: <pre> mkdir -p /usr/local/www && cd /usr/local/www </pre> * Clone the latest Odoo 13 code from GitHub: <pre> git clone https://github.com/odoo/odoo --depth 1 --branch 13.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/odoo-bin 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 "odoo-bin") "openerp-server") echo "Stopping ${name}." kill -s TERM "$(cat "${odoo_pidfile}")" echo "Stopping ${name}." kill -s TERM "${odoo_pid}" "${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 "odoo-bin") "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