How to install OpenERP 6 RC1 on Ubuntu 10.04

OpenERP 6 requires Python 2.6 and Postgres 8.4. This document describes how to install these on Ubuntu 10.04.
These instructions should be run as root on your server.

Install and configure Postgresql 8.4

1. Install Postgres 8.4

apt-get install postgresql

1a. Make sure GCC is install

apt-get install gcc

2. Allow remote PgAdmin clients access to the database: edit /etc/postgresql/8.4/main/pg_hba.conf. Add this line:

listen_addresses = ‘*’

You could tighten this address range for better security. This is completely optional

3. Create openerp user

su – postgres
createuser –createdb –no-createrole –pwprompt openerp
Enter password for new role: …..
Enter it again: …..
Shall the new role be a superuser? (y/n) y

4. Create an openerp database

createdb -O openerp openerp

5. Allow openerp-server to login to postgresql: edit /etc/postgresql/8.4/main/pg_hba.conf. Modify lines as indicated below:

# TYPE DATABASE USER CIDR-ADDRESS METHOD

# “local” is for Unix domain socket connections only
# MODIFY THE EXISTING LINE TO LOOK LIKE THIS:
local all all trust
# IPv4 local connections:
# MODIFY THE EXISTING LINE TO LOOK LIKE THIS:
host all all 127.0.0.1/32 trust
# ADD THIS LINE TO ALLOW REMOTE ACCESS; use your own IP address range:
local all all 10.10.155.0/24 trust
# IPv6 local connections:
host all all ::1/128 ident

You could tighten this address range and methods for better security.
6. Set the logging level. To tell Postgres to log all SQL activity (i.e. to see all the SELECT’s, UPDATES, DELETEs and INSERT statements), add this line to /var/lib/pgsql/data/postgresql.conf:

log_statement = ‘all’

7. Restart Postgres

service postgresql-8.4 restart

Install Python 2.6

1. Install Python and the Develment packages:

apt-get install python
apt-get install python-dev

Install packages required for OpenERP 6

1. Install setuptools:

wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz

Then unpack it and install it:

python setup.py install

2. Install easy_install:

easy_install Cython

3. Install pip:

easy_install pip

4. Use pip to make sure these packages are installed:

pip install mako
pip install pydot
pip install reportlab
pip install pyyaml
pip install pywebdav

5. Install required dependencies for OpenErp 6:
apt-get install python-psycopg2
apt-get install python-reportlab
apt-get install python-pychart
apt-get install python-pydot
apt-get install python-egenix-mxdatetime
apt-get install python-lxml
apt-get install python-tz
apt-get install python-imaging
apt-get install python-vobject
apt-get install libxml2
apt-get install libxml2-devel

6. Install libtool:

apt-get install libtool

7. Install psycopg: Download it and then install it with:

apt-get build-dep python-psycopg2

pip install psycopg

Install and configure the OpenERP 6 Server

1. Download the OpenERP6 server. Unpack it and install it:

python26 setup.py install

2. Add an openerp user:

adduser openerp

3. Make sure the new log file exists and is writable:

touch /var/log/openerp-server.log
chown openerp /var/log/openerp-server.log

4. Make sure the directory for the pidfile is writable by openerp:

mkdir /var/run/openerp
chown openerp /var/run/openerp

5. Edit ~openerp/.openerp_serverrc; make changes to look like this (don’t enter the “…” lines):

debug_mode = True
log_level = debug_rpc
root_path = /usr/local/lib/python2.6/site-packages/openerp-server
addons_path = /usr/local/lib/python2.6/site-packages/openerp-server/addons
db_host = ‘localhost’
db_port = 5432
db_user = openerp
db_name = openerp
db_password = set-your-own-password-here

6. Edit ~openerp/.bashrc

export LD_LIBRARY_PATH; LD_LIBRARY_PATH=/usr/local/lib

7. Give the OpenERP server user permission to install new modules

chown openerp /usr/local/lib/python2.6/dist-packages/addons

8. Create a startup file called /etc/init.d/openerp-server, and add it as a service. Here is the contents of the script:

#!/bin/sh

#
# OpenERP init script v0.1 for centos by Open-Future
# Bert Deferme – www.open-future.be – bert@open-future.be
#

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# For a copy of the GNU General Public License, see .

# chkconfig: 345 60 61
# description: starts the openerp-server service

NAME=openerp-server
USER=openerp

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/openerp-server
PIDFILE=/var/run/openerp/$NAME.pid
DAEMONOPTS=”–syslog –log-level=debug –pidfile=${PIDFILE}”

checkpid() {
[ -f $PIDFILE ] || return 1
pid=`cat $PIDFILE`
[ -d /proc/$pid ] && return 0
return 1
}

do_start() {

if [ -f $PIDFILE ]; then
echo “pidfile already exists: $PIDFILE”
exit 1
fi

echo -n “Starting $NAME: ”

su – $USER -c “nohup $DAEMON $DAEMONOPTS >/dev/null 2>&1 &”

sleep 3

checkpid

if [ $? -eq 1 ]; then
rm -f $PIDFILE
echo “failed.”
exit 1
fi

echo “done.”
}

do_stop() {

checkpid

if [ $? -eq 1 ]; then
echo -n “$NAME not running… (no pidfile found)”
exit 0
fi

echo -n “Stopping $NAME: ”

pid=`cat $PIDFILE`
kill -15 $pid

sleep 2

if [ $? -eq 1 ]; then
echo “Failed. (pidfile found but process didn’t exist)”
exit 1
fi

echo “done.”

}

do_status() {

echo -n “Checking $NAME: ”

checkpid

if [ $? -eq 1 ]; then
echo “stopped.”
else
echo “running.”
fi

}

do_restart() {

do_stop

if [ $? -eq 1 ]; then
exit 1
fi

do_start

}

case “$1″ in
start) do_start ;;
stop) do_stop ;;
restart|force-reload) do_restart ;;
status) do_status ;;
*)
N=/etc/init.d/$NAME
echo “Usage: $N {start|stop|restart|status}” >&2
exit 1
;;
esac

exit 0

Here is how to create it:

vi /etc/init.d/openerp-server
chmod 755 /etc/init.d/openerp-server
sudo update-rc.d openerp-server defaults
sysv-rc-conf – make sure 235 are checked off for openerp-server

9. Edit /etc/init.d/openerp-server and make the DAEMONOPTS line look like this. If file was not created see steps below to create:

DAEMONOPTS=”–logfile=/var/log/openerp-server.log –log-level=debug_rpc_answer –pidfile=${PIDFILE}”

See /usr/local/lib/python2.6/dist-packages/openerp-server/tools/config.py for other valid log levels.

10. Start the Openerp server:

service openerp-server start

Install and configure the OpenERP Web Server

1. Install the dependent, pyparsing:

should be installed if you have already installed the dependecies above, to check run
apt-get install python-pyparsing

2. Install the OpenERP Web Server

tar -xzf openerp-web….tar.gz
cd openerp-web…
sudo python setup.py install

3. Create the OpenERP Web Server configuration file:

cp /usr/local/lib/python2.6/dist-packages/openerp_web-6.0.0_rc1-py2.6.egg/openerp-web/doc /etc

4. Edit the configuration file, /etc/openerp-web.cfg. Add or uncomment lines to be like this:

log.access_file = “/var/log/openerp-web/access.log”
log.error_file = “/var/log/openerp-web/error.log”

company.url = ‘http://www.yoururl.com/your_logo.jpg’

5. Make sure the log directory /var/log/openerp-web exists and is owned by openerp.

mkdir /var/log/openerp-web
chown openerp /var/log/openerp-web

6. Create a startup file called /etc/init.d/openerp-web, and add it as a service. Here is the contents of the script:

#!/bin/sh

#
# OpenERP init script v0.1 for centos by Open-Future
# Bert Deferme – www.open-future.be – bert@open-future.be
#

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# For a copy of the GNU General Public License, see .

# chkconfig: 345 61 60
# description: runs the openerp-web service

NAME=openerp-web
USER=openerp

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/openerp-web
PIDFILE=/var/run/openerp/$NAME.pid
DAEMONOPTS=”-c /etc/openerp-web.cfg”

checkpid() {
[ -f $PIDFILE ] || return 1
pid=`cat $PIDFILE`
[ -d /proc/$pid ] && return 0
return 1
}

do_start() {

if [ -f $PIDFILE ]; then
echo “pidfile already exists: $PIDFILE”
exit 1
fi

echo -n “Starting $NAME: ”

su – $USER -c “nohup $DAEMON $DAEMONOPTS >/dev/null 2>&1 &”

pid=`ps -ef|grep openerp-web|grep -v grep|cut -d ” ” -f3`

echo $pid > $PIDFILE

sleep 3

checkpid

if [ $? -eq 1 ]; then
rm -f $PIDFILE
echo “failed.”
exit 1
fi

echo “done.”
}

do_stop() {

checkpid

if [ $? -eq 1 ]; then
echo -n “$NAME not running… (no pidfile found)”
exit 0
fi

echo -n “Stopping $NAME: ”

pid=`cat $PIDFILE`
kill -15 $pid

sleep 2

if [ $? -eq 1 ]; then
echo “Failed. (pidfile found but process didn’t exist)”
exit 1
fi

rm $PIDFILE

echo “done.”

}

do_status() {

echo -n “Checking $NAME: ”

checkpid

if [ $? -eq 1 ]; then
echo “stopped.”
else
echo “running.”
fi

}

do_restart() {

do_stop

if [ $? -eq 1 ]; then
exit 1
fi

do_start

}

case “$1″ in
start) do_start ;;
stop) do_stop ;;
restart|force-reload) do_restart ;;
status) do_status ;;
*)
N=/etc/init.d/$NAME
echo “Usage: $N {start|stop|restart|status}” >&2
exit 1
;;
esac

exit 0

Here is how to create it:

vi /etc/init.d/openerp-web
chmod +x /etc/init.d/openerp-web
sudo update-rc.d openerp-web defaults
sysv-rc-conf – make sure 235 are checked off for openerp-web

7. Start the Openerp web server:

service openerp-web start