Install ERPNext on DigitalOcean Centos 7

For followers of this saga, I started trying to install ERPNext on bare-metal FreeBSD, but ran into errors. No solution yet, so changing course slightly. I signed up for a server on DigitalOcean. It’s a pretty good deal, for $5 a month for one CPU, 512MB RAM and a 20 GB SSD. It’s basically the same as the old desktop serving dalescott.net, or the performance of a vm running in VirtualBox under Windows on my T61 ThinkPad. I also had a $10 promo code; I still had to put in $5 of my own, but I should get 3 months for $5, pretty good. I had to pick CentOS 7 instead of FreeBSD 10 (ERPNext and DigitalOcean constraints, and chosing RH for corporate familiarity), oh well….

Here are my steps, described very briefly:

  • copy my public ssh key to my DigitalOcean account (copy/paste from the PuTTYgen window, NOT the Save Public Key button!)
  • create droplet: 512 MB / 1 CPU, 20 GB SSD, 1000 GB Transfer, New York server, CentOS 7.0 x64, and use my ssh key.
  • connect to the new server using PuTTY on my Windows laptop
    • I was emailed a password, but it doesn’t seem to work, I muddled around a bit and destroyed my first droplet, so perhaps the password is for that droplet – if the second droplet got the same IP address as the destroyed one)
  • follow Easy Way in ERPNExt frappe bench README.md
    • wkhtmltopdf couldn’t be installed and was skipped (too bad, I need that!)
    • “pip-2.7 not found”, but reading setup_frappe.sh, this seems informational and not an issue
  • point browser at the server ip address
    • server produced ERPNext login screen, so it seems the basics are working.
  • install wkhtmltopdf manually (appears the project has changed its hosting recently)
    • got a LOT of “unable to allocate memory” error messages, but wkhtmltopdf seems OK (created test page, assuming errors are due to not being able to load some user thumbnail pics)
  • Access the server from a browser (port 80), and sign into ERPNext as “Adminstrator” using the password output at the end of the setup_frappe.sh execution.
  • Backup the database after completing the setup wizard.

setup_frappe.sh log

[root@firefly ~]# wget https://raw.githubusercontent.com/frappe/bench/master/install_scripts/setup_frappe.sh
--2014-11-14 22:57:47-- https://raw.githubusercontent.com/frappe/bench/master/install_scripts/setup_frappe.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 199.27.76.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|199.27.76.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11601 (11K) [text/plain]
Saving to: ‘setup_frappe.sh’

100%[============================================================>] 11,601 --.-K/s in 0s

2014-11-14 22:57:47 (37.0 MB/s) - ‘setup_frappe.sh’ saved [11601/11601]

[root@firefly ~]# sudo bash setup_frappe.sh --setup-production
Installing for centos 7 amd64 In case you encounter an error, you can post on https://discuss.frappe.io

Adding centos mariadb repo
Installing packages for centos. This might take time...
Installing wkhtmltopdf
Cannot install wkhtmltodpdf. Skipping...
Configuring CentOS services
Starting services
Adding frappe user
setup_frappe.sh: line 300: hash: pip-2.7: not found
Installing frappe-bench Setting up first site

Frappe/ERPNext is installed successfully and is running on port 80.
Frappe password: xxxxxxxxxxxxxxxx
MariaDB root password: xxxxxxxxxxxxxxxx
Administrator password: xxxxxxxxxxxxxxxx

The passwords are also stored at ~/frappe_passwords.txt
You can remove this file after making a note of the passwords. 
[root@firefly ~]#

install wkhtmltopdf

[root@firefly ~]# wget http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.1/wkhtmltox-0.12.1_linux-centos7-amd64.rpm
--2014-11-14 23:30:03--  http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.1/wkhtmltox-0.12.1_linux-centos7-amd64.rpm
Resolving downloads.sourceforge.net (downloads.sourceforge.net)... 216.34.181.59
Connecting to downloads.sourceforge.net (downloads.sourceforge.net)|216.34.181.59|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://softlayer-dal.dl.sourceforge.net/project/wkhtmltopdf/0.12.1/wkhtmltox-0.12.1_linux-centos7-amd64.rpm [following]
--2014-11-14 23:30:03--  http://softlayer-dal.dl.sourceforge.net/project/wkhtmltopdf/0.12.1/wkhtmltox-0.12.1_linux-centos7-amd64.rpm
Resolving softlayer-dal.dl.sourceforge.net (softlayer-dal.dl.sourceforge.net)... 67.228.157.232
Connecting to softlayer-dal.dl.sourceforge.net (softlayer-dal.dl.sourceforge.net)|67.228.157.232|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14258268 (14M) [application/octet-stream]
Saving to: ‘wkhtmltox-0.12.1_linux-centos7-amd64.rpm’

100%[=============================================================================================================>] 14,258,268  5.16MB/s   in 2.6s

2014-11-14 23:30:06 (5.16 MB/s) - ‘wkhtmltox-0.12.1_linux-centos7-amd64.rpm’ saved [14258268/14258268]

[root@firefly ~]#
[root@firefly ~]# rpm -ivh wkhtmltox-0.12.1_linux-centos7-amd64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:wkhtmltox-1:0.12.1-1             ################################# [100%]
[root@firefly ~]# yum install fontconfig libXrender libXext '*fonts*' openssl
...
  Lots and LOTS of fonts appear to be installed, but at the end there are a LOT of "[Errno 5] [Errno 12] Cannot allocate memory"
[root@firefly ~]# wkhtmltopdf --version
wkhtmltopdf 0.12.1 (with patched qt)
[root@firefly ~]# wkhtmltopdf http://www.tecmint.com/install-eclipse-classic-in-rhel-centos-fedora/ ./install-eclipse.pdf
Loading pages (1/6)
Warning: A finished ResourceObject received a loading finished signal. This migth be an indication of an iframe taking to long to load.
Warning: A finished ResourceObject received a loading progress signal. This migth be an indication of an iframe taking to long to load.
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Exit with code 1 due to network error: UnknownNetworkError
[root@firefly ~]#

Backup database

systemctl status mariadb.service
mysqldump -u root -p --databases site1.local > ~/erpnextbkup/erpnext-1.sql

Restore database

mysql -u root -p site1.local < ~/erpnextbkup/erpnext-1.sql

Flattening a directory structure on Windows

The other day I needed to copy all the files within a hierarchical directory structure in a shared network directory into a single directory. Here’s how I did it.

1) install the following GnuWin32 utilities from http://gnuwin32.sourceforge.net/packages.html (this is much simpler than and add the bin directory (c:\Program Files\GnuWin32\bin) to your PATH environment variable.

  • CoreUtils
  • FindUtils
  • sed

2) Check the shared network directory for files with the same name, and either change names or delete files before copying. My shared network directory is mapped as I:\Share.

C:\>I:
I:\>cd I:\Share
I:\Share>"c:\Program Files\GnuWin32\bin\find.exe" . -type f | sed "s/.*\///" | sort | uniq -d

The full path to “find” is needed because, although the GnuWin32 bin directory is on my command path, the Windows “find” command is found on my path before the GnuWin32 “find”. This can take some time – 15 minutes on a 5 year old laptop with a shared directory having 170k files and 22K directories!

3) Copy the files into a new “files” directory on X-drive:

I:\Share>mkdir X:\files
I:\Share>cp `find . -type f` X:\files

Done!

P.S. Thanks to ldenneau for the idea (http://ask.metafilter.com/62308/Easy-Windows-directory-flattening-with-minimal-tools)

Maestro Business Processes

I envision a whole library of worked examples for new users, showing how various workflows can be implemented. A set of worked “happy paths” or a “Workflow Recipes for Dummies” if you will.

SCC data is available from the Maestro project.

Business Model

The Swift Construction Company (SCC) manufactures a radio receiver called an  Aircraft Wireless.  The SCC buys an assembled electronics circuit board (Part Number 20000003) in lots of 10 from Trilogy-Net.  The circuit boards are used to manufacture Aircraft Wireless units (PN 10000003). When circuit boards from Trilogy-Net arrive at the SCC, they are inspected and, if acceptable, identified with a serial number and stored on a shelf. One of the SCC’s customers is B&E Submarines, who some time ago purchased an Aircraft Wireless system from the SCC to evaluate.

The products (part numbers), customer (B&E) and supplier (Trilogy-Net) have been created. Two BoMs have been created, one for the finished Aircraft Wireless product (PN 10000003) and one for a spare parts kit (PN 60000001), which includes the electronics circuit board (PN 20000003).

Scenario 1

Explore serial numbers in the context of a customer purchase. B&E Submarines desires to purchase a spare parts kit for the Aircraft Wireless unit they previously purchased. A serialized circuit board is used in the assembly of the spare parts kit (preferably a phantom-type BoM to make the parts in it visible), which is then sold and delivered to B&E.

Sometime later, Ed Bentley calls from B&E. He says he found a circuit board, but he doesn’t know if it’s the circuit board from the spares kit. He’s not sure but he thinks the original board might have failed, and he swapped it with the one from the spare parts kit. Ed wants to know if the serial number on the board is the same as the board shipped in the spare parts kit he bought.

Scenario 2

Explore serial numbers in the context of a project. B&E Submarines plans to upgrade 5 of their submarines with Aircraft Wireless systems. A contract is negotiated between the SCC and B&E, and the SCC initiates a Project to capture all related activity (of which the physical receiver units are only one portion). Complete radio receivers PN 10000003 are manufactured, each with its own serial number – traceable to the serialized electronics circuit board inside. The completed radio receivers are sold and delivered to B&E as part of the overall project.

Sometime later, Ed Bentley calls from B&E. He has a circuit board in his hand again, and wants to know where the serial number came from. Ed asks if the circuit board was from one of the 5 receivers delivered as part of the upgrade project.

Summary

Although these scenarios may seem short, attempting to implement them will indicate a great deal about the capabilities of the underlying ERP system.

 

Installing OpenERP 7.0 using BitNami OpenERP 7.0 Stack

Fred Blauer recommended I take a look at OpenERP based on my described use case of PLM, Manufacturing, and Inventory Management.

I have been casually following OpenERP since v4.x (it was called TinyERP then), but had never configured a server – primarily because OpenERP used separate server and client, and I wanted a pure server system. However, I was pleasantly surprised when I took a look at the current OpenERP 7.0. OpenERP is now a pure web application, and BitNami has a free OpenERP Stack, including an Ubuntu-based virtual machine (in VMware format but also supported by VirtualBox). I’ll get the vm running first on my Win7 laptop with VirtualBox, and describe my experiences using OpenERP in a future post.

Create server

  • Download BitNami OpenERP Stack virtual machine (vm) to a Windows machine on my local network.
  • Using VirtualBox, create a new vm with characteristics: Linux/Ubuntu 64b OS with 1.5GB RAM, but do not configure a boot drive. I originally tried the suggested 512MB RAM, but the system was thrashing (as seen by memory use in ‘top’), with very poor performance.
  • Extract the files from the downloaded vm zip file into the directory VirtualBox created for the new vm.
  • Configure the new vm using VirtualBox Manager.
    • Network: Bridged (to have access from other machines in my network).
    • Storage: bitnami-openerp-7.0-3-ubuntu-12.04.vmdk (included in the BitNami vm download and copied to the vm directory).
  • Boot the new vm.

After booting, the console will display the server IP address and other helpful information (the IP address shown will likely differ in your environment):

*** Welcome to the BitNami OpenERP Stack ***
*** Built using Ubuntu 12.04 - Kernel 3.2.0-31-virtual (tty1). ***
*** You can access the application at 192.168.10.124 ***
*** The default username and password is 'user' and 'bitnami'. ***
*** Please refer to http://wiki.bitnami.com/Virtual_Machines for details. ***

******************************************************************************
*  To access the console, please use user 'bitnami' and password 'bitnami'.  *
*                                                                            *
*                                 WARNING                                    *
*  For security reasons, upon your first login, you will be prompted to      *
*  change the default password.                                              *
******************************************************************************

linux login:

If you copied the system drive for the vm from one host computer to another, the vm may report “The machine could not configure the network interface” after booting. This will occur if VIrtualBox provides a different Ethernet MAC ID on the second computer than on the first, and Ubunto creates a new Ethernet interface for a new interface MAC ID but is still configured for the interface on the first computer. Got it? “ifconfig -a” shows the Ethernet devices identified during boot, and “dmesg | grep eth” will show the network interface renaming. In this case, edit /etc/network/interfaces to specify the appropriate network interface (e.g. eth1 instead of eth0). See: http://www.howtogeek.com/168143/fixing-failed-to-bring-up-eth0-in-ubuntu-virtual-machine/ and http://gist.github.com/percursoaleatorio/6881040.

Login to the VirtualBox terminal using the provided username/password (bitnami/bitnami), and set a new password when prompted e.g. appleton (i.e. bitnami/appleton).

Enable ssh login

  • Configure sshd for remote login and scp file transfer.
$ sudo cp /etc/init/ssh.conf.back /etc/init/ssh.conf
$ sudo start ssh

PostgreSQL

My initial goal was to use pgadmin3 for viewing and managing PostgreSQL databases on the vm from my laptop.

  • Edit postgresql.conf so PostgreSQL will listen on all IP addresses.
$ sudo vi /opt/bitnami/postgresql/data/postgresql.conf
...
listen_addresses = '*'                  # what IP address(es) to listen on;
...
  • Restart PostgreSQL. I tried using pg_ctl but it wouldn’t initially run because of missing libraries. I solved this by adding the BitNami common libraries and the PostgreSQL libraries to LD_LIBRARY_PATH in ~/.bashrc (and logged out and back in again).
$ vi ~/.bashrc
...
# for BitNami Stack PostgreSQL
LD_LIBRARY_PATH=/opt/bitnami/postgresql/lib:/opt/bitnami/common/lib
export LD_LIBRARY_PATH
...

However, this just led to other problems – the user to run pg_ctl as, whether the unset environment variable PGDATA is an issue, etc. I’m sure this isn’t how BitNami intends this to work (fwiw, /opt/bitnami/ctlscript.sh seems to be the intended control point for everything), but

Finally I just rebooted the vm, but pgadmin3 still wouldn’t connect. Perhaps it’s a firewall problem…

However, the PostgreSQL psql cli utility can be used (the password for the bitnami_openerp database is ‘bitnami’):

bitnami@linux:~$ psql bitnami_openerp
Password:
psql.bin (9.2.4)
Type "help" for help.

bitnami_openerp=# help
You are using psql, the command-line interface to PostgreSQL.
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit
bitnami_openerp=#

For more information on psql, see the PostgreSQL psql documentation.

Configure OpenERP

The BitNami OpenERP stack vm includes a database called bitnami_openerp (Administrator username/password: user/bitnami). I’m going to create a new database from scratch and install the basic modules needed to support Maestro workflows.

Access the vm from a workstation browser. The IP address for the vm is shown in the vm terminal window after booting (or after logging out).

  • Create a new database (company). The PostgreSQL master (super-administrator) password is “bitnami”, and I’ll use “appleton” for the new database password. OpenERP will create a new database with an administrative user (username/password: admin/appleton) and a demo user (username/password: demo/demo), and will login to the database as the administrator.

You will likely see a “timezone mismatch” warning in the top bar of the window. This is because the timezone set in your user preferences (which was configured by BitNami when they created the OpenERP stack) is different from the timezone your browser believes you are in (which comes from your workstation). You can access your user preferences by clicking the drop-down menu beside your username in the top bar of the window.

Install the following OpenERP applications using the Modules > Apps menu:

        • MRP (Manufacturing Orders, Bill of Materials, Routing)
        • Project Management (Projects, Tasks)
        • Issue Tracker (Support, Bug Tracker, Helpdesk)
        • Warehouse Management (Inventory, Logistic, Storage)

You will be prompted for your OpenERP user id and password (free to register) to start, and for any required configurations as each application is installed. Applications often have dependency applications, which will be automatically installed.

If you want to experiment with pre-defined demo data, select Manage Databases in the login screen and create a new database selecting “Install Demo Data”. The new database will be configured with a basic set of applications and demo data.

Still to do

Now that I’ve got OpenERP installed, the top items on my To Do list are:

  • Learn how OpenERP works! Create a couple users, import Maestro bills of materials, manufacture some serialized items using un-controlled, batch controlled and serialized raw material, etc.
  • Learn more about host OpenERP and Python web applications in general using WSGI by examining the BitNami OpenERP Stack (/opt/bitnami/apache2/conf/httpd.conf includes a WSGI reference).
  • Install OpenERP on FreeBSD. As of 2014-03-20, there is a binary package available for OpenERP 7.0, but it will still take time to understand how to make it usable.

Related information

For more information on OpenERP, a great reference is the OpenERP Book.

 

Updated since first posting 2013-07-22.