Running Odoo 8.0 As A Service

blog-banner

Below is the complete guide for installing Odoo 8.0 server in Ubuntu 12.04 and running this server as a service. We use “ubuntu” named user for below process. You can use username from which you logged in the system.

Step 1: Install postgres and pgAdmin.

  • First execute the below command to update the package lists from the repositories and updates them to get information on the newest versions of packages and their dependencies.
sudo apt-get update
  • Execute below command to install postgres and pgAdmin3

sudo apt-get install postgresql-9.1 pgadmin3

Step 2: Start Postgres

sudo su postgres

Step 3: Create user in postgres provide password for that user.

screateuser -P -s -e ubuntu (Same as Machine name)

Step 4 : Open new terminal and install python requirements by following commands.

sudo apt-get install python-dateutil python-decorator python-docutils python-feedparser \python-gdata python-gevent python-imaging python-jinja2 python-ldap python-libxslt1 python-lxml \python-mako python-mock python-openid python-passlib python-psutil python-psycopg2 python-pybabel \python-pychart python-pydot python-pyparsing python-pypdf python-reportlab python-requests \python-simplejson python-tz python-unittest2 python-vatnumber python-vobject python-werkzeug \python-xlwt python-yaml wkhtmltopdf 

Step 5: Download openERP/odoo for Linux platform from the below site.

https://www.odoo.com/page/download

Or you can download source from github which is more preferable options that provides more flexibility during development and deployment of any module.

https://github.com/odoo/odoo/releases

Extract the server and rename it to “odoo”. Copy this folder to “/opt/odoo/” folder(If “odoo” folder in “/opt” does not exists then create this folder).

Step 6: Create configuration file for openerp server.

  • Create “openerp-server.conf” file and copy and paste below content.
[options]
; This is the password that allows database operations: 
admin_passwd = password for admin 
sdb_host = localhost 
db_port = 5432 
db_user = ubuntu 
db_password = password for postgres database user 
addons_path = /opt/odoo/odoo/openerp/addons (It may change according to your downloaded bundle)
logfile = /var/log/openerp/openerp-server.log 

Provide password in the admin_passwd. Here, db_user = ubuntu and db_password = ***** are for the user created in postgres for ubuntu user.

  • Copy “openerp-server.conf” file to “/etc” folder, and change odoo server’s folder ownership and permissions by executing below commands. Execute useradd command only if the you want to give other user permission for that folder.

useradd -d /opt/odoo/odoo -s /bin/bash ubuntu 
chown ubuntu: -R /opt/odoo/odoo 
chown ubuntu: /etc/openerp-server.conf 
chown ubuntu: /etc/openerp-server.conf 

Step 7:  Install the boot script

  • Create an “openerp-server” file with the following content and copy-paste this file in “/etc/init.d/” folder.

#!/bin/sh s
### BEGIN INIT INFO 
# Provides: odoo-server 
# Required-Start: $remote_fs $syslog 
# Required-Stop: $remote_fs $syslog 
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Business Applications 
### END INIT INFO
PATH=/bin:/sbin:/usr/bin
PATH=/bin:/sbin:/usr/bin 
DAEMON=/opt/odoo/odoo/openerp-server (It may change according to your downloaded bundle) 
NAME=openerp-server
DESC=openerp-server 

 # Specify the user name (Default: openerp).
USER=ubuntu

# Specify an alternate config file (Default: /etc/odoo-server.conf).
CONFIGFILE="/etc/openerp-server.conf"

 # pidfile
PIDFILE=/var/run/$NAME.pid 

 # Additional options that are passed to the Daemon.
DAEMON_OPTS="-c $CONFIGFILE"
[ -x $DAEMON ] || exit 0
[ -f $CONFIGFILE ] || exit 0
checkpid() {
[ -f $PIDFILE ] || return 1
pid=`cat $PIDFILE`
[ -d /proc/$pid ] && return 0
return 1 
}

case "${1}" in
start)
echo -n "Starting ${DESC}: "
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--chuid ${USER} --background --make-pidfile \
--exec ${DAEMON} -- ${DAEMON_OPTS}
echo "${NAME}."
;;
stop)
echo -n "Stopping ${DESC}: "
start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \
--oknodo
echo "${NAME}."
;;

restart|force-reload) echo -n "Restarting ${DESC}: "
start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \
--oknodo
sleep 1
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--chuid ${USER} --background --make-pidfile \
--exec ${DAEMON} -- ${DAEMON_OPTS}
echo "${NAME}."
;;
*)
N=/etc/init.d/${NAME}
echo "Usage: ${NAME} {start|stop|restart|force-reload}" >&2
exit 1
;;

esac
exit 0
  • Make this file executable using the following commands :

	chmod 755 /etc/init.d/openerp-server 
	chown ubuntu: /etc/init.d/openerp-server 

Step 8 : Create a log file for the odoo server and make this file executable using the following commands.

mkdir /var/log/openerp
chown ubuntu: /var/log/openerp
touch /var/log/openerp/openerp-server.log
chmod 777 /var/log/openerp/openerp-server.log

Step 9 : Start the server

/etc/init.d/openerp-server start

To view logs of the server execute below command.

tail -f /var/log/openerp/openerp-server.logs

Now you can access the odoo server by hitting the “localhost:8069” in web browser.

Step 10 : Once the server started successfully then make this server start and stop automatically using below command.

sudo update-rc.d openerp-server defaults

First time when you start the server there will be no database created for the odoo so it will redirect the user to the “Manage Databases” page. In this page create a database that you want to use by providing the master password same as you provide in “openerp-server.conf”  file and that’s it !! Enjoyy !!

Contact us

For Your Business Requirements

Text to Identify Refresh CAPTCHA
Background Image Close Button

2 - 4 October 2024

Hall: 10, Booth: #B8 Brussels, Belgium