Wednesday, February 23, 2011

Installing OpenERP 6 Server on Mac OS X 10.6 (Snow Leopard)

*** Updated 8/11/2011 for OpenERP 6.0.2 ***

If you are like me and own your own business, it can be overwhelming at times trying to keep all your ducks in a row. OpenERP is a flexible solution for enterprise resource planning that is versatile enough to manage both large corporations and small proprietorships. It integrates your product catalog with an e-commerce website and point-of-sale while managing your employees and financial accounts; it's an all around system for business management at your fingertips.

If you're interested in a free online demo you can check out http://www.openerp.com/online - but if you're like me and need total control over the system, you can bring it all in-house with the instructions below.

Since OpenERP is Open Source software you can download and use it for free to manage your business, but installation and configuration can be a little tricky - so that's where this tutorial comes in. Our server is running Mac OS X 10.6.8 and we will be installing OpenERP 6.0.2 (current as of 8/11/11). This tutorial has not been tested on Mac OS X 10.7 Lion. If anyone has had success with Apple's latest and greatest OS please comment below.

Installing OpenERP Server
Step 1: We're going to use MacPorts to install the dependencies required by OpenERP. The latest version at the time of this writing is 2.0.1 but any later version should work and install the same. Download the version of MacPorts for Snow Leopard and run the installer package to get started. NOTE: MacPorts requires the Xcode developer tools. They can be found on your Mac OS X 10.6 Install DVD or downloaded from the Apple Developer Connection website.

Step 2: Join the Apple Developer Connection (their FREE membership will suffice) and download/install the Java for Mac OS X 10.6 Developer Package which contains the Java header files required by some of the dependencies.

Step 3: Install PostgreSQL 9.0.4 using the EnterpriseDB bundle available here. During the installation it will ask you where you want certain files installed. I used the following settings for organizational reasons:
  • Installation Directory: /Library/PostgreSQL/9.0
  • Data Directory: /Library/Server/PostgreSQL/Data 
  • Server Port: 5432
Open /Applications/Utilities/Terminal.app and type in the following commands to add the PostgreSQL bin directory to the database user's PATH:

johndoe$ sudo -i
Password: *enter your user password here*
root# export PGHOME=/Library/PostgreSQL/9.0
root# echo 'export PATH=/Library/PostgreSQL/9.0/bin:$PATH' >> $PGHOME/.profile
root# exit
logout


Step 4: We need to create a database user account that OpenERP will use to connect to PostgreSQL. The following commands should be entered into Terminal.app to create the openerp database user:

johndoe$ sudo su - postgres
Password: *enter your user password here*
postgres$ createuser --createdb --no-createrole --pwprompt openerp
Enter password for new role: *enter the openerp database user's password*
Enter it again: *enter the openerp database user's password - again*
Shall the new role be a superuser? (y/n) n
Password: *enter the postgres user's password*
postgres$ exit
logout


Step 5: Type the following commands into Terminal.app to install the OpenERP Server dependencies:

johndoe$ sudo -i
Password: *enter your user password here*
root# port install python26
root# port select python python26
root# export PATH=/Library/PostgreSQL/9.0/bin:$PATH
root# port install py26-setuptools; easy_install setuptools
root# port install py26-psycopg2 +postgresql90; easy_install psycopg2
root# port install py26-reportlab; easy_install reportlab
root# port install py26-lxml; easy_install lxml
root# port install py26-tz; easy_install pytz
root# port install py26-yaml; easy_install PyYaml
root# port install py26-mako; easy_install mako
root# port install py26-dateutil; easy_install DateUtils
root# port install graphviz +python26 +no_x11
root# port install py26-parsing; easy_install pyparsing
root# port install py26-pil; easy_install pil


Step 6: In order to run OpenERP securely we need to create an unprivileged system user. The following command displays a list of current users on the system - the numbers on the right are their user ids. You need to chose a unique user id that is not in the list for the new OpenERP user (preferable the next id in the 500 sequence).

root# dscl . -list /Users UniqueID
root# export NEW_USER_ID=*the unique id you have chosen for the openerp user*


Now we can run the following commands to create the new unprivileged openerp user:

root# dscl . -create /Users/openerp
root# dscl . -create /Users/openerp UniqueID $NEW_USER_ID
root# dscl . -create /Users/openerp NFSHomeDirectory /var/empty
root# dscl . -create /Users/openerp UserShell /bin/sh
root# dscl . -create /Users/openerp PrimaryGroupID 1
root# dscl . -create /Users/openerp RealName "OpenERP User"
root# dscl . -create /Users/openerp Password "*"
root# exit
logout


Step 7: Now that all the dependencies have been satisfied, download the OpenERP 6.0.2 Server Sources and move openerp-server-6.0.2.tar.gz to your Desktop. Double-click the archive to decompress and extract its contents. You should now have a directory named openerp-server-6.0.2 in your ~/Desktop folder. To install OpenERP Server run the following commands in Terminal.app:

johndoe$ cd ~/Desktop/openerp-server-6.0.2
johndoe$ sudo python setup.py install


Step 8: Now that OpenERP Server has been installed we need to configure it to run automatically when the computer is turned on, but first we need to configure the /Library/Server directory to secure the files we will put there. The following also creates a Logs folder where OpenERP Server logs will be stored.

johndoe$ sudo -i
Password: *enter your user password here*
root# cd /Library/Server
root# chown root:admin ./; chmod 0775 ./
root# chown -R postgres:wheel ./PostgreSQL; chmod 0770 ./PostgreSQL
root# mkdir -p ./OpenERP/Configuration
root# cd ./OpenERP
root# touch ./Configuration/openerp-server.conf
root# mkdir ./Logs
root# chown -R openerp:wheel ./; chmod -R 0770 ./


Use the following command to create the openerp-server.conf file in the /Library/Server/OpenERP/Configuration directory:

root# pico -w ./Configuration/openerp-server.conf

You can then paste the following into the text editor that opens. Make sure you update the file to include the correct admin_passwd and db_password:

[options]
without_demo = True
; This is the password that allows database operations:
admin_passwd = ***enter your database admin password here***
upgrade = False
verbose = False
netrpc = True
; netrpc_interface =
; netrpc_port =
xmlrpc = True
; xmlrpc_interface =
xmlrpc_port = 8069
db_host = localhost
db_port = 5432
; Please uncomment the following line *after* you have created the
; database. It activates the auto module check on startup.
db_name = False
db_user = openerp
db_password = ***enter the openerp database user password here***
; Uncomment these for xml-rpc over SSL
; secure = True
; secure_cert_file = /etc/openerp/server.cert
; secure_pkey_file = /etc/openerp/server.key
root_path = /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/openerp-server
soap = False
translate_modules = ['all']
demo = {}
addons_path = None
reportgz = False
; Static http parameters
static_http_enable = False
static_http_document_root = /var/www/html
static_http_url_prefix = /


Use Ctrl-x to close the file and enter y when prompted whether or not to save it. Now for the startup script:

root# cd /Library/LaunchDaemons
root# pico -w com.openerp.openerpserver.plist


Again you can just copy and paste the following text into the editor. This time there are no substitution that need to be made:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>EnvironmentVariables</key>
<dict>
<key>PY_USE_XMLPLUS</key>
<string></string>
<key>PATH</key>
<string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/X11R6/bin:/opt/local/bin:/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin</string>
</dict>
<key>UserName</key>
<string>openerp</string>
<key>Label</key>
<string>com.openerp.openerpserver</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/openerp-server</string>
<string>-c</string>
<string>/Library/Server/OpenERP/Configuration/openerp-server.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceDescription</key>
<string>OpenERP Server</string>
<key>StandardOutPath</key>
<string>/Library/Server/OpenERP/Logs/OpenERP-Server.out</string>
<key>StandardErrorPath</key>
<string>/Library/Server/OpenERP/Logs/OpenERP-Server.err</string>
</dict>
</plist>


Step 9: At this point OpenERP Server should be fully installed and configured. You can now run the following command to start the server - no restart necessary.

root# launchctl load ./com.openerp.openerpserver.plist
root# exit
logout


The next tutorial will cover building the OpenERP 6.0.2 Client on Mac OS X 10.6 (Snow Leopard). I hope that someone finds this helpful. Please leave comments below.

10 comments:

  1. Hi,
    Thank for the tuto.
    I've done it and tried to install webclient as well.
    I'm not a terminal user and i seem ti be stuck at this point.
    Have you written the next tuto, can't find it.
    If you could give me a hand...
    Thanks

    ReplyDelete
  2. +1 for the next tuto on installing the web client.

    and thanks for this guide, it works well (10.6.7)

    ReplyDelete
  3. Hi,

    Thanks for this tuto.

    I had several problems and here are the workarounds :
    - add /opt/local/bin to PATH
    - add ARCHFLAGS="-arch i386 -arch x86_64" because of XCode 4 (see http://stackoverflow.com/questions/5256397/python-easy-install-fails-with-assembler-for-architecture-ppc-not-installed-on)
    - port install py26-distribute; easy-install distribute
    - port -f activate py26-distribute

    +1 for the next tuto on installing the web client

    ReplyDelete
  4. someone try this on Lion (10.7) ?

    ReplyDelete
  5. Very nice for me.... many thanks

    ReplyDelete
  6. Yeah it work on my Lion (10.7.2)
    with little bit modify
    Thanks

    ReplyDelete
  7. Please Help!

    johndoe$ cd ~/Desktop/openerp-server-6.0.2
    johndoe$ sudo python setup.py install

    Installation take this directories:

    desktop/openerp-server-6.0.2/build/lib/openerp-server

    not here

    /Library/Server

    openerp 504
    postgres 503

    root# dscl . -read /Users/openerp
    AppleMetaNodeLocation: /Local/Default
    GeneratedUID: **************
    NFSHomeDirectory: /var/empty
    Password: *****
    PrimaryGroupID: 1
    RealName:
    OpenERP User
    RecordName: openerp
    RecordType: dsRecTypeStandard:Users
    UniqueID: 504
    UserShell: /bin/sh

    Thanks

    ReplyDelete
  8. Not so far I have found new cool tool to work on mac os x - Valentina Studio. Its free edition can do things more than many commercial tools!!
    I very recommend check it. http://www.valentina-db.com/en/valentina-studio-overview
    You can install Valentina Studio (FREE) directly from Mac App Store: https://itunes.apple.com/us/app/valentina-studio/id604825918?ls=1&mt=12

    ReplyDelete