OpenBSD Installation: LedgerSMB 1.3.x on OpenBSD -current

Submitted by Chris Travers on

This content is outdated and kept here for reference only!

IMPORTANT NOTE: The instructions on this page, are retained for historical purposes only.
For Up To Date installation instructions please refer to Installing LedgerSMB

Content by Chris Bennett, (source: ledger-smb-devel mail list: and
Edited by Havard Sorli
This tutorial may not be complete, please help us make it better.
Date: 30-12-2011

These instructions are for base Apache included with OpenBSD, not Apache2.
I have not yet gotten LedgerSMB fully functional in chrooted Apache.

I do not intend to continue experimenting until I find a complete answer, as I now run all mod_perl, so please start Apache with:
# httpd -u

A possible method to get faster responses would be to run mod_perl using PerlRun.But I still see that needing to be outside the chroot due to need for LaTeX.

Prepare Apache for use.
Make suexec setuid:
# chmod 4755 /usr/sbin/suexec

Check the file /etc/fstab
The /var partition is set by default to nosuid (no setuser id):

/dev/wd0a / ffs rw 1 1
/dev/wd0d /tmp ffs rw,nodev,nosuid 1 2
/dev/wd0g /usr ffs rw,nodev 1 2
/dev/wd0f /var ffs rw,nodev,nosuid 1 2
/dev/wd0h /home ffs rw,nodev,nosuid 1 2

This might not allow Apache to function correctly.
If you have any problems, you can change:

/dev/wd0f /var ffs rw,nodev,nosuid 1 2
/dev/wd0f /var ffs rw,nodev 1 2

Edit /etc/rc.conf.local to have the following:
# use -u to disable chroot, see httpd(8)

httpd_flags="-u" # for normal use: "" (or "-DSSL" after reading ssl(8))

You will need to reboot because you cannot umount /var.

Install Needed Packages

Specify a PKG_PATH, for OpenBSD -current, use a similar command:
# export PKG_PATH=
Note: http:// package sources tend to make more stable connections.
You may be able to install some of the optional packages on earlier release versions. I have not verified it.
Then add PostgreSQL server and client:
# pkg_add -i postgresql-server
This will add the server and will also add the client package.

To use the PostgreSQL server you have to create a database first.
You find detailed instructions on how to install a database in the file
/usr/local/share/doc/pkg-readmes/postgresql-server-9.1.1p0 (numbers will agree with your version)
Please read this file completely, as it contains useful information.
Which contains, as needed for LedgerSMB installation (as of -current):

Using PostgreSQL in an OpenBSD environment

At least two different accounts are involved when working with PostgreSQL:
One is an OpenBSD userid, '_postgresql', which is used as the userid of files
that are part of PostgreSQL. The other, usually named 'postgres', is not an
OpenBSD userid, i.e. you will not find it in /etc/passwd, but an account
internal to the database system. The 'postgres' account is called the dba
account (database administrator) and is created when a new database is
initialized using the initdb command.

If you are installing PostgreSQL for the first time, you have to create
a default database first. In the following example we install a database
in /var/postgresql/data with a dba account 'postgres' and md5 authentication.
We will be prompted for a password to protect the dba account:

# su - _postgresql
$ mkdir /var/postgresql/data
$ initdb -D /var/postgresql/data -U postgres -A md5 -W

Please note that by default the cluster's encoding will be SQL_ASCII. If you want to have an another default encoding, use the option -E with initdb. If your cluster is already created, you can specify an another encoding when you create a new database with this command:

Follow the steps for creating a superuser - postgres - above.

You will need to enter a superuser password for postgres. This is NOT the same as the passwords you will use later on!
You should also read the man page for rc.d. This is how postgres is now started and stopped.
If you want PostgreSQL to start and stop on boot and shutdown, add the following to /etc/rc.conf.local:

Now follow the instructions to start PostgreSQL server:
$ pg_ctl -D /var/postgresql/data -l logfile start

This step needs to be done while still operating as _postgresql user. Then you should exit as that user.
$ exit
You could also reboot if you wish to check that everything is working correctly in /etc/rc.conf.local.

Add additional needed packages:
# pkg_add -i p5-Module-Install

# pkg_add -i p5-DBI
# pkg_add -i p5-DBD-Pg
# pkg_add -i p5-MIME-Lite

# pkg_add -i p5-Class-Std
# pkg_add -i p5-HTML-Tagset
# pkg_add -i p5-Data-Dump

# pkg_add -i p5-Test-Tester
# pkg_add -i p5-HTML-Parser
# pkg_add -i p5-Test-Trap

# pkg_add -i p5-Math-BigInt-GMP
# pkg_add -i p5-Locale-Maketext-Lexicon Must be 0.62 or greater

# pkg_add -i texlive_base
# pkg_add -i p5-Config-Std Use CPAN if unavailable, this is required
# pkg_add -i p5-CGI-Simple

# pkg_add -i p5-File-MimeInfo
# pkg_add -i p5-DateTime
# pkg_add -i p5-Log-Log4perl

# pkg_add -i gsed For some command line scripts
# pkg_add -i p5-Template-Plugin-Latex This one is essential for PDF and Postscript output

# pkg_add -i p5-Parse-RecDescent (optional for CLI host scripts)

Note: OpenBSD -current may soon offer the following ports and/or packages:
I have included unofficial copies of these as ports at: Ports for OpenBSD that meet requirements for LedgerSMB

# pkg_add -i p5-LaTeX-Driver
# pkg_add -i p5-LaTeX-Encode
# pkg_add -i p5-LaTeX-Table

# pkg_add -i p5-MooseX-FollowPBP
# pkg_add -i p5-MooseX-Param
# pkg_add -i p5-Excel-Template

# pkg_add -i p5-Excel-Template-Plus
# pkg_add -i p5-Net_TCLink
# pkg_add -i p5-XML-Twig

DO NOT use CPAN to install a later version of Locale::Maketext::Lexicon than 0.79, as it is not compatible with Locale::Maketext used in base perl!
You will have to search for this version on CPAN, it is not available on the release page!

Next run the following:
# perl Makefile.PL
# make
# make test
# make install
# make clean

Then run this, choosing a company name and where the postgresql contrib directory is at (check this first!):
./tools/ --company testinc --pgsql-contrib /usr/local/share/postgresql/contrib
For a list of other options you may wish to change, use:
./tools/ --help

I like to use command line stuff more than GUI stuff.
I did not find at this time that using through the web interface would work. asked me many times for ledgersmb password. Ugh.
I decided it was easier to install from command line after I set up a .pgpass

file with both postgres and new ledgersmb.
This will eliminate needing to enter passwords multiple times.
This file can be kept, edited or discarded after installation.
This file must have mode 0600.


Problems I had, that may already be patched

I had 3 problems with

-if ! options=$( getopt -u -l company:,coa:,gifi:,srcdir:,dstdir:,password:,host:,port:,help,progress,pgsql-contrib: '' "$@" )
+if ! options=$( getopt company:,coa:,gifi:,srcdir:,dstdir:,password:,host:,port:,help,progress,pgsql-contrib: '' "$@" )

For OpenBSD, bash has to be added. sh/ksh is standard.
This fails in sh and bash for me.
If we drop the -u -l, will that work OK for others?


-cat <<EOF | su -c "psql -U postgres -d postgres " postgres 2>&1 | unchatter
+cat <<EOF | psql -U postgres -d postgres 2>&1 | unchatter

I even tried changing this to OpenBSD's user _postgresql and reordering it, but I couldn't get this to work with su -c
It works fine for me like second one.
Is there any need for su -c for others to use psql?


ERROR: language \"plpgsql\" already exists|\
-)/d" -

In sub unclutter, dropping the dash at the end lets it work with OpenBSD's sed which is different than GNU sed.
Why is there a dash there?
With the dash, it would be necessary to use gsed instead of sed.

Copy ledgersmb-httpd.conf to the directory where you keep Apache conf files. Probably at /var/www/conf/modules.
Stop and restart Apache:
# apachectl stop
# httpd -u
# httpd -u -DSSL

Last Updated December 27, 2011