Forums

Lam Nguyen
Lam Nguyen
Offline
Resolved
0 votes
As you know OpenERP is a comprehensive suite of business applications including Sales, CRM, Project management, Warehouse management, Manufacturing, Financial management and Human Resources just to name a few.
It's build up from Ubuntu so it's work perfect on Ubuntu, but now in this tutorials you can deploy it on ClearOS (formed from RHEL 6) for painless. I used Openerp 6.1 source tarball from here and add some dependency from another repositories.
In my case it work perfect but I don't warranty it work for you! so be careful at you own risk.
I'm Vietnamese so in some grammar is not good, hopefully you still understanding. Sorry for you inconvenience.

Step 1. Build your ClearOS 6.2 cummunity

Add repo
rpm
-Uhv http://archive.download.redhat.com/pub/redhat/linux/6.2/en/os/i386/RedHat/RPMS/redhat-release-6.2-1.noarch.rpm

-Uhv http://apt.sw.be/redhat/el6/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.i686.rpm

-Uhv http://ftp.cuhk.edu.hk/pub/linux/fedora-epel/6/SRPMS/epel-release-6-6.src.rpm

-Uhv http://ftp.cuhk.edu.hk/pub/linux/fedora-epel/6/i386/epel-release-6-6.noarch.rpm

yum update

If you don't wan to that repo you can disable it through web config laster.

Step 2. Create the OpenERP user that will own and run the application

groupadd openerp

useradd -r -b /opt -g openerp openerp
This is a "system" user. It is there to own and run the application, it isn't supposed to be a person type user with a login etc. In ClearOS, a system user gets a UID below 1000, has no shell (it's actually /bin/false) and has login disabled. Note that I've specified a "home" of /opt/openerp, this is where the OpenERP server code will reside and is created automatically by the command above. The location of the server code is your choice of course, but be aware that some of the instructions and configuration files below may need to be altered if you decide to install to a different location.
When you have done what you need you can leave the openerp user's shell by typing exit.

Step 3. Install and configure the database server, PostgreSQL

yum install postgresql postgresql-server

chkconfig postgresql on

service postgresql initdb

service postgresql start

su - postgres
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt openerp

Finally exit from the postgres user account:

exit

Step 4. Install the necessary Python libraries for the server

yum install python python-setuptools python-ldap python-ldaphelper PyXML python-psycopg2 pychart pydot libxml2-python python-lxml libxslt-python pytz postgresql-python graphviz python-imaging python-devel postgresql-server openldap-clients python-feedparser python-gdata libxslt python-openid babel pychart pydot pyparsing python-vatnumber python-vobject python-werkzeug python-pip python-reportlab python-mako
easy_install simplejson

easy_install http://pyyaml.org/download/pyyaml/PyYAML-3.10.tar.gz

easy_install xlwt
easy_install zsi

easy_install PyWebDAV
or you can search source from python: http://www.python.org/

Step 5. Install the OpenERP server
I tend to use wget for this sort of thing and I download the files to my home directory.
Make sure you get the latest version of the application. At the time of writing this it’s 6.1-1; I got the download links from their download page.
wget http://nightly.openerp.com/6.1/releases/openerp-6.1-1.tar.gz
Now install the code where we need it:
cd to the /opt/openerp/ directory and extract the tarball there.

cd /opt/openerp
tar xvf ~/openerp-6.1-1.tar.gz
Next we need to change the ownership of all the the files to the OpenERP user and group.
chown -R openerp: *

And finally, the way I have done this is to copy the server directory to something with a simpler name so that the configuration files and boot scripts don’t need constant editing (I called it, rather unimaginatively, server). I started out using a symlink solution, but I found that when it comes to upgrading, it seems to make more sense to me to just keep a copy of the files in place and then overwrite them with the new code. This way you keep any custom or user-installed modules and reports etc. all in the right place.
cp -a openerp-6.1-1 server
As an example, should OpenERP 6.1-2 come out soon, I can extract the tarballs into /opt/openerp/ as above. I can do any testing I need, then repeat the copy command so that the modified files will overwrite as needed and any custom modules, report templates and such will be retained. Once satisfied the upgrade is stable, the older 6.1-1 directories can be removed if wanted.

Step 6. Configuring the OpenERP application
On ClearOS or Centos and RHEL 6 OpenERp don’t work with Python 2.6.6 it requires upgrade to 2.7 but updating python 2.6.6 from source to 2.6.7 is a huge adventure, I just replaced the file ir_model.py modified by Olivier:

cd /opt/openerp/server/openerp/addons/base/ir

http://bazaar.launchpad.net/~openerp/openobject-server/trunk/files/4090/openerp/addons/base/ir/ir_model.py

and RPM building was ok.

python setup.py bdist_rpm

The default configuration file for the server (in /opt/openerp/server/install/) is actually very minimal and will, with only one small change work fine so we’ll simply copy that file to where we need it and change it’s ownership and permissions:
cp /opt/openerp/server/install/openerp-server.conf /etc/

chown openerp: /etc/openerp-server.conf

chmod 640 /etc/openerp-server.conf
The above commands make the file owned and writeable only by the openerp user and group and only readable by openerp and root.
To allow the OpenERP server to run initially, you should only need to change one line in this file.
Toward to the top of the file change the line db_password = False to the same password you used back in step 3. Use your favourite text editor here. I tend to use nano, e.g.
nano /etc/openerp-server.conf
One other line we might as well add to the configuration file now, is to tell OpenERP where to write its log file. To complement my suggested location below add the following line to the openerp-server.conf file:
logfile = /var/log/openerp/openerp-server.log
Once the configuration file is edited and saved, you can start the server just to check if it actually runs.
su - openerp -s /bin/bash
/opt/openerp/server/openerp-server
If you end up with a few lines eventually saying OpenERP is running and waiting for connections then you are all set. Just type CTL+C to stop the server then exit to leave the openerp user’s shell.
If there are errors, you’ll need to go back and check where the problem is.

Step 7. Installing the boot script

For the final step we need to install a script which will be used to start-up and shut down the server automatically and also run the application as the correct user. There is a script you can use in /opt/openerp/server/install/openerp-server.init but this will need a few small modifications to work with the system installed the way I have described above. Here’s a script attached to the one I’ve already modified for ClearOS:
#!/bin/bash
# openerp-server This shell script takes care of starting and stopping
# OpenERP server
#
# chkconfig: 345 95 05
# description: OpenERP server
#
# pidfile: /var/run/openerp-server.pid
# config: /etc/openerp-server.conf

### BEGIN INIT INFO
# Provides: openerp-server
# Required-Start: postgresql
# Required-Stop: postgresql
# Should-Start: $network harddrake
# Default-Start: 345
# Short-Description: Launches the OpenERP server.
# Description: This startup script launches the OpenERP server.
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

PIDFILE=/var/run/openerp/openerp-server.pid
LOCKFILE=/var/lock/subsys/openerp-server
LOGFILE=/var/log/openerp/openerp-server.log

OPTS="--pidfile=$PIDFILE --logfile=$LOGFILE"

prog="openerp-server"
desc="OpenERP Server Daemon"

# check if the openerp-server conf file is present, then use it
if [ -f /etc/openerp-server.conf ]; then
OPTS="$OPTS -c /etc/openerp-server.conf"
fi

# Source function library
if [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
exit 0
fi

# check the existence of the openerp-server script
[ -z "/opt/openerp/server/openerp-server" ] && exit 0

RETVAL=0

start() {
if [ -d /etc/openerp/start.d ] ; then
echo -n $"Preparing $desc: "
run-parts --exit-on-error /etc/openerp/start.d
RETVAL=$?
echo
[ $RETVAL -ne 0 ] && return $RETVAL
fi

echo -n $"Starting $desc ($prog): "
daemon --user openerp --check openerp-server \
"/usr/bin/setsid /opt/openerp/server/openerp-server \
-c /etc/openerp-server.conf \
--pidfile=$PIDFILE \
--logfile=$LOGFILE &"

RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCKFILE
return $RETVAL
}

stop() {
echo -n $"Stopping $desc ($prog): "
kill -TERM `cat $PIDFILE` > /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
rm -f $LOCKFILE

echo_success
echo
else
echo_failure
echo
fi
if [ -d /etc/openerp/stop.d ] ; then
echo -n $"Clearing $desc: "
run-parts /etc/openerp/stop.d
echo
fi
return $RETVAL
}

restart() {
stop
start
}

condrestart() {
[ -e $LOCKFILE ] && restart || :
}

status() {
if [ -f $PIDFILE ] ; then
checkpid `cat $PIDFILE`
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
echo $"$prog is running..."
else
echo $"$prog is stopped"
fi
else
echo $"$prog is stopped"
fi
return $RETVAL
}

case "$1" in
start)
start
;;

stop)
stop
;;

restart|reload)
restart
;;

condrestart)
condrestart
;;

status)
status
;;

probe)
exit 0
;;

*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
exit 1
esac

Similar to the configuration file, you need to either copy it or paste the contents of this script to a file in /etc/init.d/ and call it openerp-server. Once it is in the right place you will need to make it executable and owned by root:
chmod 755 /etc/init.d/openerp-server
chown root: /etc/init.d/openerp-server
In the configuration file there’s an entry for the server’s log file. We need to create that directory first so that the server has somewhere to log to and also we must make it writeable by the openerp user:
mkdir /var/log/openerp

chown openerp:root /var/log/openerp
mkdir /var/run/openerp
chown openerp:root /var/run/openerp

Step 8. Testing the server
To start the OpenERP server type:
/etc/init.d/openerp-server start
You should now be able to view the logfile and see that the server has started.
less /var/log/openerp/openerp-server.log
If there are any problems starting the server you need to go back and check. There’s really no point ploughing on if the server doesn’t start…

If the log file looks OK, now point your web browser at the domain or IP address of your OpenERP server (or localhost if you are on the same machine) and use port 8069. The url will look something like this:

http://IP_or_domain.com:8069
What you should see is a screen like this one:
http://www.clearfoundation.com/media/kunena/attachments/legacy/images/Screen_Shot_2012_07_07_at_4.png
What I do recommend you do at this point is to change the super admin password to something nice and strong (Click the “Manage Databases” link below the main Login box). By default this password is just “admin” and knowing that, a user can create, backup, restore and drop databases! This password is stored in plain text in the /etc/openerp-server.conf file; hence why we restricted access to just openerp and root. When you change and save the new password the /etc/openerp-server.conf file will be re-written and will have a lot more options in it.
Now it’s time to make sure the server stops properly too:
/etc/init.d/openerp-server stop
Check the logfile again to make sure it has stopped and/or look at your server’s process list.


Step 9. Automating OpenERP startup and shutdown
If everything above seems to be working OK, the final step is make the script start and stop automatically with the Server. To do this type:

chkconfig --add openerp-server
chkconfig openerp-server on

You can now try rebooting you server if you like. OpenERP should be running by the time you log back in.

If you type ps aux | grep openerp you should see a line similar to this:

openerp 1491 0.1 10.6 207132 53596 ? Sl 22:23 0:02 python /opt/openerp/server/openerp-server -c /etc/openerp-server.conf

Which shows that the server is running. And of course you can check the logfile or visit the server from your web browser too.

Step 10. Apache rewrite and SSL Reverse Proxy to you Openerp Server
For security we only allows OpenERP access from LAN you must edit the openerp-server.conf in /etc like:

xmlrpc = True
xmlrpc_port = 8069
xmlrpc_interface = 127.0.0.1

netrpc = True
netrpc_port = 8070
netrpc_interface = 127.0.0.1

But in case if you need access it from internet we user SSL and reverse proxy to you Openerp server:
in this step I’ll describe one way of providing SSL encrypted access to your shiny new OpenERP 6.1 server running on.
first we need a certificate file:
I create the files in a temporary directory then move them to their final resting place once they have been built (the first cd is just to make sure we are in our home directory to start with):

cd
mkdir temp
cd temp

Then we generate a new key, you will be asked to enter a passphrase and confirm.

openssl genrsa -des3 -out server.pkey 1024

We don’t really want to have to enter a passphrase every time the server starts up so we remove the passphrase by doing this:

openssl rsa -in server.pkey -out server.key

Next we need to create a signing request which will hold the data that will be visible in your final certificate:

openssl req -new -key server.key -out server.csr

This will generate a series of prompts like this: Enter the information as requested

And finally we self-sign our certificate.

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

We only need two of the files in the working directory, the key and the certificate. But before we can use them they need to have their ownership and access rights altered:

chown openerp:root server.crt server.key
chmod 640 server.crt server.key

And then we put them in a sensible place:

mkdir /etc/ssl/openerp
chown openerp:root /etc/ssl/openerp
chmod 710 /etc/ssl/openerp
mv server.crt server.key /etc/ssl/openerp/

Now the key and certificate are safely stored away, we can tell Apache where they are:

Second go to web config: Server/Web Serve and make a new sub domain like: erp.youdomain.com
nano /etc/httpd/conf.d/your-sudomain.conf and insert this code:
<VirtualHost *:80>
ServerName erp.xxxx.com
ServerAlias erp.xxxx.com
Redirect permanent / https://erp.xxxx.com/
TransferLog /var/log/httpd/transfer.web.openerp.log
</VirtualHost>
<VirtualHost *:443>
ServerName erp.xxx.com
ServerAlias erp.xxxx.com
SSLProxyEngine on
SSLEngine on
SSLCertificateFile /etc/ssl/openerp/server.crt
SSLCertificateKeyFile /etc/ssl/openerp/server.key
SSLCACertificateFile /etc/ssl/openerp/server.crt
RequestHeader set "X-Forwarded-Proto" "https"
SetEnv proxy-nokeepalive 1
ProxyPass / http://127.0.0.1:8069/
ProxyPassReverse / http://127.0.0.1:8069/
ProxyErrorOverride off
TransferLog /var/log/httpd/transfer.web.openerp.log
#Fix IE problem (httpapache proxy dav error 408/409)
SetEnv proxy-nokeepalive 1
</VirtualHost>


service httpd restart

and now check if it work correctly when you type erp.xxx.com it will rewrite to: https://erp.xxxxxx.com/web

That is all I know!
Saturday, July 07 2012, 10:08 AM
Share this post:
Responses (3)
  • Accepted Answer

    Thursday, July 19 2012, 11:27 AM - #Permalink
    Resolved
    0 votes
    I am so happy,of stumble with this, i'm planning to build a SMB with some features like that: ECM, ERP , LDAP, Flexshares. When ClearOs 6.3 have release.
    The reply is currently minimized Show
  • Accepted Answer

    Gerry Reno
    Gerry Reno
    Offline
    Saturday, July 07 2012, 03:38 PM - #Permalink
    Resolved
    0 votes
    The last time I looked at OpenERP (5.x version) it had some serious flaws as far as accounting foundation.

    It appeared as though it was written by people with no formal accounting education.

    Unless the accounting foundation of the software was rewritten since 5.x, I would not recommend it.

    .
    The reply is currently minimized Show
  • Accepted Answer

    Saturday, July 07 2012, 11:52 AM - #Permalink
    Resolved
    0 votes
    Thanks OpenBravo is a great peace of opensource software for the commercial market.

    Have you done anything with OpenBravoPos ?

    Also it would be so good to have this in the ClearOS Marketplace.

    ClearOS is a great SMB application server.

    Many Thanks

    Stuart

    Whoops just noticed OpenErp :)

    Damn have been waiting for OpenBravo on ClearOS for ages :)
    The reply is currently minimized Show
Your Reply