Installing OpenERP especially for a new comer would be a little bit difficult at first, not because OpenERP itself is difficult to install, but if you follow the official documentation then probably you have chances to mess things up since the doc is not 100% up-to-date and it is somewhat misleading with all the comments from various users.
Here I am going to guide you how to install OpenERP running as a service. The recent releases of debian based distros has
OpenERP as deb package so one can easily install it with a synaptic package management system, but instead here I am going to show you how to install an OpenERP server and web client from source and then run it as a service.
Server : Ubuntu 10.04 (Lucid Lynx) OpenERP version : 5.0.14 PostgreSQL version : 8.4 Python version : 2.6 You need administrative (sudo) privilages on the server.
Login to the server as an administrative user (sudo). We first need to install a PostgreSQL server if it is not already installed.
$ sudo apt-get install postgresql
Then we need to create a PostgreSQL database user for openerp. For doing this you need to switch to PostgreS user.
$ sudo su – postgres
$ createuser --createdb --username postgres --no-createrole --pwprompt openerp
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) n
$ exit
Now if you try to login to the database as this user, you will get an error.
$ psql -U openerp -W
$ psql: FATAL: Ident authentication failed for user "openerp"
To fix this we need to change PostgrSQLl configuration so that it uses ident based authentication instead of password based authentication.
$ sudo vi /etc/postgresql/8.4/main/pg_hba.conf
change the line
#local all all ident
to
local all all md5
then it should be as following
# Database administrative login by UNIX sockets
local all postgres ident
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# “local” is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# IPv6 local connections:
host all all ::1/128 md5
Now download OpenERP server and web client to a convenient location. I downloaded them to the OpenERP directory created in my home directory.
$ mkdir ~/openerp
$ cd ~/openerp
$ wget http://www.openerp.com/download/stable/source/openerp-server-5.0.14.tar.gz
$ wget http://www.openerp.com/download/stable/source/openerp-web-5.0.14.tar.gz
Extract the server and web archives.
$ tar zxvf openerp-server-5.0.14.tar.gz
$ tar zxvf openerp-web-5.0.14.tar.gz
Installing OpenERP-server
To install the OpenERP server execute the setup script.
$ cd ~/openerp/openerp-server-5.0.14
$ sudo python setup.py install
The server is normally installed to /usr/local/lib/python2.6/dist-packages/openerp-server
Now you can run the server in console by executing the command.
$ openerp-server --db_user=openerp --db_password=<password>
Installing openerp-web
First you need to install the required libraries for the openerp-web.
$ sudo apt-get install python-psycopg2 python-reportlab python-egenix-mxdatetime python-tz python-pychart python-pydot python-lxml python-vobject python-profiler
Also install python-dev and build-essential if they are not already installed.
$sudo apt-get install python-dev build-essential
$sudo apt-get install python-setuptools
Now change to the lib directory in the extracted openerp-web and run the populate.sh script. This will install all the dependencies required.
$ cd ~/openerp/openerp-web-5.0.14/lib
$ ./populate.sh
$ cd ..
Now you can run the web client by executing openerp-web in console.
$ openerp-web
You should be getting the following output.
[03/Nov/2010:10:11:35] ENGINE Bus STARTING
[03/Nov/2010:10:11:35] ENGINE Started monitor thread ‘_TimeoutMonitor’.
[03/Nov/2010:10:11:35] ENGINE Started monitor thread ‘Autoreloader’.
[03/Nov/2010:10:11:35] ENGINE Serving on 0.0.0.0:8080
[03/Nov/2010:10:11:35] ENGINE Bus STARTED
Running openerp-web as a service
Copy following openerp-web scripts from the installation directory in to specified locations.
$ sudo cp /usr/local/lib/python2.6/dist-packages/openerp_web-5.0.6-py2.6.egg/scripts/openerp-web /etc/init.d/
(This is the init script used to start/stop openerp-web)
$sudo cp /usr/local/lib/python2.6/dist-packages/openerp_web-5.0.6-py2.6.egg/config/openerp-web.cfg /etc/
(This is the openerp-web configuration file)
Grant execute permission to /etc/init.d/openerp-web
$sudo chmod +x /etc/init.d/openerp-web
Edit /etc/init.d/openerp-web file. In the file we need to provide the user who runs openerp. First we need to create new system user for this. I named mine as ‘openerp’.
$ useradd openerp
( this is the system user for running the server and web-client )
$ sudo vim /etc/init.d/openerp-web
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DAEMON=/usr/local/bin/openerp-web
USER=”your system username”
Next edit /etc/openerp-web.cfg and specify the log files.
$ sudo gedit /etc/openerp-web.cfg
log.access_file = “/var/log/openerp-web/access.log”
log.error_file = “/var/log/openerp-web/error.log”
Lets create the log file directory and grant ownership to openerp user.
$ sudo mkdir /var/log/openerp-web/
$ sudo chown openerp /var/log/openerp-web/
Now run following command to start the OpenERP Web automatically on system startup (Debian/Ubuntu).
$ sudo update-rc.d openerp-web defaults
Now you can start the daemon like this:
$ sudo /etc/init.d/openerp-web start
Running openerp-server as a service
I could not find an init script for server in installation directory. So lets create a one.
$ sudo vim /etc/init.d/openerp-server
And enter the following script.
#!/bin/sh
### BEGIN INIT INFO
# Provides: openerp-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Enterprise Resource Management software
# Description: Open ERP is a complete ERP and CRM software.
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DAEMON=/usr/local/bin/openerp-server
NAME=openerp-server
DESC=openerp-server
USER=openerp
test -x ${DAEMON} || exit 0
set -e
case “${1}” in
start)
echo -n “Starting ${DESC}: “
start-stop-daemon –start –quiet –pidfile /var/run/${NAME}.pid \
–chuid ${USER} –background –make-pidfile \
–exec ${DAEMON} — –config=/etc/openerp-server.conf
echo “${NAME}.”
;;
stop)
echo -n “Stopping ${DESC}: “
start-stop-daemon –stop –quiet –pidfile /var/run/${NAME}.pid \
–oknodo
echo “${NAME}.”
;;
restart|force-reload)
echo -n “Restarting ${DESC}: “
start-stop-daemon –stop –quiet –pidfile /var/run/${NAME}.pid \
–oknodo
sleep 1
start-stop-daemon –start –quiet –pidfile /var/run/${NAME}.pid \
–chuid ${USER} –background –make-pidfile \
–exec ${DAEMON} — –config=/etc/openerp-server.conf
echo “${NAME}.”
;;
*)
N=/etc/init.d/${NAME}
echo “Usage: ${NAME} {start|stop|restart|force-reload}” >&2
exit 1
;;
esac
exit 0
Grant execute permissions to this script.
$ sudo chmod +x /etc/init.d/openerp-server
The following will make it run automatically on system startup.
$ sudo update-rc.d openerp-server defaults
Now we need to create a config file for the server. The server reads the config settings in the file on startup.
$ sudo vim /etc/openerp-server.conf
[options]
# Enable the debugging mode (default False).
verbose = False
debug_mode = False
# The file where the server pid will be stored (default False).
#pidfile = /var/run/openerp.pid
# The file where the server log will be stored (default False).
logfile = /var/log/openerp-server.log
# The unix account on behalf openerp is running.
process_user = openerp
# The IP address on which the server will bind.
# If empty, it will bind on all interfaces (default empty).
interface = localhost
# The TCP port on which the server will listen (default 8069).
#port = 8070
# Enable debug mode (default False).
debug_mode = False
# Launch server over https instead of http (default False).
secure = False
# Specify the SMTP server for sending email (default localhost).
smtp_server = localhost
# Specify the SMTP user for sending email (default False).
smtp_user = False
# Specify the SMTP password for sending email (default False).
smtp_password = False
# Specify the database name.
db_name = False
# Specify the database user name (default None).
db_user = openerp
# Specify the database password for db_user (default None).
db_password = <password_for_openerp_user>
# Specify the database host (default localhost).
db_host = localhost
# Specify the database port (default None).
db_port = 5432
# Specify the price accuracy.
#price_accuracy =
#Specify the addons path
addons-path = /usr/local/lib/python2.6/dist-packages/openerp-server/addons/
Lets create the server log file and grant the ownership to OpenERP user.
$ sudo touch /var/log/openerp-server.log
$ sudo chown openerp /var/log/openerp-server.log
That’s it. Now you can start the server by executing
$ sudo /etc/init.d/openerp-server start
Now from a web browser navigate to OpenERP. You will get the OpenERP login screen.
http://yourdomain:8080