Thursday, October 1, 2015

Install Odoo V9.0 with Nodejs on Ubuntu 14.04



I have tried out V9.0. and this round , it is not SO easy to install , so in this article , from what i learn and i will share here hopefully can help you all to try out Odoo V9.0 !
You can download a .deb or .rpm file of odoo 9 from https://github.com/odoo/odoo and install it in the ubuntu or any other debian distribution. This How to guide will allow you to install odoo v9.0.

1. Update The System

First get newest versions possible as per version requirements of dependencies of packages existing on the machine using.
$sudo apt-get update
$sudo apt-get dist-upgrade

2. Create User

Create Odoo System User that will own and run the odoo application.
$sudo adduser --system --home=/opt/odoo --group odoo

Here we have specified /opt/odoo as home, so when ever you change user to odoo it will by default land to /opt/odoo.
we gonna put all the odoo code under /opt/odoo. you can change the path of your choice, and do the configuration accordingly.

After creating user you can try the login with the created user by below command.
$sudo su - odoo -s /bin/bash



3. Install and Configure Postgres Database

$sudo apt-get install postgresql

This command will install postgres 9.1 by default in ubuntu 14.04 or any debian distribution. if you want to use any specific version of postgres(i.e 9.3, 9.4) you need to update the source list. for example to install postgres-9.4 you can follow below steps.
Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository using vim or nano editor
$deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
Import the repository signing key, and update the package lists
$wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
and update the packages using
$sudo apt-get update
after that you can search/install the available/supported postgres version
$sudo apt-get install postgresql-9.4
After installing postgres 9.4, change to the postgres user so we have the necessary privileges to configure the database
$sudo su - postgres
Now create a new database user with access to create and drop database.
$createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo

4. Install the necessary libraries

$sudo apt-get install python-pip python-dev libevent-dev gcc libxml2-dev libxslt-dev node-less libldap2-dev libssl-dev

Note
Odoo 9 depends on node-less
You may probably missing a dependency for lessc, here are the instructions to get lessc working correctly, 
  • On Linux, you can simply use their setup script.
    $ wget -qO- https://deb.nodesource.com/setup | bash -
    $ apt-get install -y nodejs
    $apt-get install node-less                                                                                                   Once you have npm working, install less and less-plugin-clean-css.
    $ sudo npm install -g less less-plugin-clean-css
    On debian and Ubuntu you also need to set a symbolic link from nodejs to node because the shebang line of lessc uses node.
    $ sudo ln -s /usr/bin/nodejs /usr/bin/node 
  • sudo apt-get install libv8-dev
  • PLEASE RESTART SERVER or you may be facing error of : node: error while loading shared libraries: libv8.so.3.14.5: cannot open shared object file: ...if after restarted the server , the error still not yet resolve then please install Odoo V9.0. BLOG module , after i installed the module , it work properly.
  • On OS X, install nodejs via your preferred package manager (macports, homebrew) then install less and less-plugin-clean-css.

  • $ sudo npm install -g less less-plugin-clean-css
  • On Windows, install nodejs then reboot and install less and less-plugin-clean-css.

    C:>npm install -g less less-plugin-clean-css

After installing this system libraries we can install python libraries using pip. Create or use the  requirement.txt file  distributed in Odoo server.

Here is information for how to change the directory to /tmp, and get the official requirement.txt from Odoo V9.0 github repository to install it in your system. it will reduce steps to install the python dependency to install odoo 9 in your server.
$cd /tmp & $rm requirements.txt & $wget https://raw.githubusercontent.com/odoo/odoo/9.0/requirements.txt $sudo pip install -r requirements.txt
After all the dependencies installed ,Odoo 9.0 should be ready to install .
for Qweb templating we need to install wkhtmltopdf. download deb file of  wkhtmltopdf 32 bit orwkhtmltopdf 64 bit.
Assumed  we have downloaded wkhtmltopdf into /tmp directory. You can go to the directory and run the following command to install.
for 64 bit:
$sudo dpkg -i /tmp/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
for 32 bit:
$sudo dpkg -i /tmp/wkhtmltox-0.12.2.1_linux-trusty-i386.deb


5. Install the Odoo server

Install Git:
$sudo apt-get install git
Switch to the Odoo user  :
$sudo su - odoo -s /bin/bash
$git clone https://www.github.com/odoo/odoo --depth 1 --branch 9.0 --single-branch .


6. Other Information


6.1. Error of uploading images for Odoo V9.0 in ubuntu 14.04
Root Cause: Pillow (JPEG decoder) bug on ubuntu > 14.04

Resolution: update jpeg library, then reinstall pillow.

# install libjpeg-dev with apt
sudo apt-get install libjpeg-dev

# reinstall pillow
pip install -I pillow

# restart Odoo, or else no effect until it is restarted.
6.2. Configuring the Odoo application
The default configuration file for the server is under /opt/odoo/debian/openerp-server.conf. we’ll copy that file to where we need it and change it’s ownership and permissions:
$sudo cp /opt/odoo/debian/openerp-server.conf /etc/odoo-server.conf
$sudo chown odoo: /etc/odoo-server.conf
$sudo chmod 640 /etc/odoo-server.conf
Above commands make the file owned and writable only by the odoo user and group and only readable by odoo and root.
To allow odoo to use default addons you need to change the addons_path line in config file from addons_path = /usr/lib/python2.7/dist-packages/openerp/addons in the config file to addons_path = /opt/odoo/addons. (Please refer to the documents on how to write your own config file )
you can also change other line as per your server deployment needs.
6.3. Installing the Init script
This script will be used to start-up and shut down the odoo server automatically and also run the application as the defined user. we will user script /opt/odoo/debian/init by doing few small modifications. Here’s a sample of the startup script  for Odoo 9.


#!/bin/bash
### BEGIN INIT INFO
# Provides:          odoo.py
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start odoo daemon at boot time
# Description:       Enable service provided by daemon.
# X-Interactive:     true
### END INIT INFO
## more info: http://wiki.debian.org/LSBInitScripts\
. /lib/lsb/init-functions
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DAEMON=/opt/odoo/odoo.py
NAME=odoo
DESC=odoo-server
CONFIG=/etc/odoo/odoo-server.conf
LOGFILE=/var/log/odoo/odoo-server.log
PIDFILE=/var/run/${NAME}.pid
USER=odoo
export LOGNAME=$USER

test -x $DAEMON || exit 0
set -e

function _start() {
    start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER:$USER --background --make-pidfile --exec $DAEMON -- --config $CONFIG --logfile $LOGFILE
}
function _stop() {
    start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --retry 3
    rm -f $PIDFILE
}
function _status() {
    start-stop-daemon --status --quiet --pidfile $PIDFILE
    return $?
}
case "$1" in
        start)
                echo -n "Starting $DESC: "
                _start
                echo "ok"
                ;;
        stop)
                echo -n "Stopping $DESC: "
                _stop
                echo "ok"
                ;;
        restart|force-reload)
                echo -n "Restarting $DESC: "
                _stop
                sleep 1
                _start
                echo "ok"
                ;;
        status)
                echo -n "Status of $DESC: "
                _status && echo "running" || echo "stopped"
                ;;
        *)
                N=/etc/init.d/$NAME
                echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
                exit 1
                ;;
esac
exit 0

Now you need to either copy it or paste the contents of this script to a file in /etc/init.d/ and call it odoo-server. and you need to make it executable and owned by root:
$sudo chmod 755 /etc/init.d/odoo-server
$sudo chown root: /etc/init.d/odoo-server
we also need to make log file /var/log/odoo/odoo-server.log and give proper access rights using the following commands ,

create odoo directory under /var/log/
$sudo mkdir /var/log/odoo
go to the directory
$cd /var/log/odoo
create file
$touch odoo-server.log
give the permission to writable by the odoo user
$sudo chmod 755 /var/log/odoo/odoo-server.log
$sudo chown odoo:root -R /var/log/odoo/
6.4. Testing the new odoo server
To start the Odoo server type:
$sudo /etc/init.d/odoo-server start
You should now be able to view the log file and see that the server has started.
$sudo tail -f /var/log/odoo/odoo-server.log

If the log file looks OK, now point your web browser at the domain or IP address of your Odoo server which by default use port 8069. try below in your browser
http://IP_or_domain.com:8069
for the first time you will see database manager to create your first database.
Now it’s time to make sure the server stops properly too:
$sudo /etc/init.d/odoo-server stop
Check the log file again to make sure odoo has stopped properly.
$sudo tail -f /var/log/odoo/odoo-server.log
6.5. Automate startup for Odoo server 
If everything working well above then we will  make an entry of odoo-sever in update-rc.d which will automatically start & stops the odoo server along with ubuntu,
$sudo update-rc.d odoo-server defaults
you can try rebooting your server to check whether the odoo service is working fine or not.
Hope you enjoy odoo v9.0 . Should you find any problems of this instruction , please write your comments and we will try to solve it and update the documents to benefit the rest of the users.

1 comment:

  1. addition to 6.1 (the notorious pillow error),
    If you're upgrading from v7 environment, and the fresh v9 server installation keep showing error:
    (even after previous step has been done)
    Browser "Internal Server Error"
    "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."
    error log: "IOError: decoder jpeg not available"
    then your new v9 installation is corrupted.

    if continue run the server, you'll get other irrelevant errors,
    i.e. "Qwebtemplate not found: External ID not found...", "OperationalError: Unable to use a closed cursor...",
    that would lead you to the other end of the world.

    Just drop the corrupted database,
    stop the odoo service,
    $ pip uninstall PIL
    $ pip uninstall Pillow
    then remove them from Python Library.
    example in Ubuntu 14.04,
    $ rm /usr/local/bin/python2.7/dist-packages/PIL
    $ rm /usr/local/bin/python2.7/dist-packages/Pillow
    (and whatever related egg folders)
    reboot
    $ pip install pillow

    OK, now enjoy creating your new odoo v9~

    ReplyDelete

Note: Only a member of this blog may post a comment.