Installing PostgreSQL 7.3.4



These are my notes on the steps took to compile the open source database PostgreSQL on White Box Enterprise Linux 3. PostgreSQL is a high performance relational database capable of performing comparably with commercial databases such as Oracle (certainly for web apps anyway). Version 7.3.4 is the current recommended version for use with the OpenACS toolkit. It is freely available from

White Box Enterprise Linux is an open source version of Red Hat Enterprise Linux and is freely available from

The main part of these notes are taken from the PostgreSQL installation documentation for OpenACS. If you intend to use OpenACS you should review that documentation as it includes other steps, explanations, and scripts for other Linux flavours.


A few libraries and the compiler were not installed by default on my system. Depending on the options you chose when you installed White Box, you may also need to install the gcc compiler (we're stuck without it!), the readline source (to enable command line editing in psql) and the zlib source (used for database dumps) as below.

As root:

mount /dev/cdrom cd /mnt/cdrom/RedHat/RPMS rpm -Uvh glibc-kernheaders-2.4-8.34.i386.rpm rpm -Uvh glibc-headers-2.3.2-95.20.i386.rpm rpm -Uvh glibc-devel-2.3.2-95.20.i386.rpm rpm -Uvh gcc-3.2.3-34.i386.rpm rpm -Uvh readline-devel-4.3-5.i386.rpm rpm -Uvh zlib-devel-1.1.4-8.1.i386.rpm

Compile and install PostgreSQL

As root, create the postgres user, which we'll use to run the database:

cd /usr/local/src tar xzf /tmp/postgresql-7.3.4.tar.gz groupadd web useradd -g web -d /usr/local/pgsql postgres mkdir -p /usr/local/pgsql chown -R postgres.web /usr/local/pgsql /usr/local/src/postgresql-7.3.4 chmod 750 /usr/local/pgsql

Configure the user's environment by adding these lines to ~postgres/.bash_profile:

export PATH=/usr/local/bin/:$PATH:/usr/local/pgsql/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/pgsql/lib

Do the compile & install as postgres. These steps may take a few minutes:

cd /usr/local/src/postgresql-7.3.4 ./configure --enable-locale --enable-multibyte --enable-syslog --enable-unicode-conversion --enable-recode make all make install

Start PostgreSQL and install Pl/pgSQL

As postgres:

/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/server.log start createlang plpgsql template1 createlang -l template1

Auto start/stop

As root, create the file /etc/rc.d/init.d/postgresql:

#! /bin/sh # chkconfig: 2345 98 02 # description: PostgreSQL RDBMS # This is an example of a start/stop script for SysV-style init, such # as is used on Linux systems. You should edit some of the variables # and maybe the 'echo' commands. # # Place this file at /etc/init.d/postgresql (or # /etc/rc.d/init.d/postgresql) and make symlinks to # /etc/rc.d/rc0.d/K02postgresql # /etc/rc.d/rc1.d/K02postgresql # /etc/rc.d/rc2.d/K02postgresql # /etc/rc.d/rc3.d/S98postgresql # /etc/rc.d/rc4.d/S98postgresql # /etc/rc.d/rc5.d/S98postgresql # Or, if you have chkconfig, simply: # chkconfig --add postgresql # # Proper init scripts on Linux systems normally require setting lock # and pid files under /var/run as well as reacting to network # settings, so you should treat this with care. # Original author: Ryan Kirkpatrick <> # $Header: /cvsroot/pgsql/contrib/start-scripts/linux,v 1.3 2001/07/30 ## EDIT FROM HERE # Installation prefix prefix=/usr/local/pgsql # Data directory PGDATA="/usr/local/pgsql/data" # Who to run pg_ctl as, should be "postgres". PGUSER=postgres # Where to keep a log file PGLOG="$PGDATA/server.log" ## STOP EDITING HERE # Check for echo -n vs echo \c if echo '\c' | grep -s c >/dev/null 2>&1 ; then ECHO_N="echo -n" ECHO_C="" else ECHO_N="echo" ECHO_C='\c' fi # The path that is to be used for the script PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # What to use to start up the postmaster DAEMON="$prefix/bin/pg_ctl" set -e # Only start if we can find pg_ctl. test -f $DAEMON || exit 0 # Parse command line parameters. case $1 in start) $ECHO_N "Starting PostgreSQL: "$ECHO_C su - $PGUSER -c "$DAEMON start -D '$PGDATA' -s -l $PGLOG" echo "ok" ;; stop) echo -n "Stopping PostgreSQL: " su - $PGUSER -c "$DAEMON stop -D '$PGDATA' -s -m fast" echo "ok" ;; restart) echo -n "Restarting PostgreSQL: " su - $PGUSER -c "$DAEMON restart -D '$PGDATA' -s -m fast" echo "ok" ;; status) su - $PGUSER -c "$DAEMON status -D '$PGDATA'" ;; *) # Print help echo "Usage: $0 {start|stop|restart|status}" 1>&2 exit 1 ;; esac exit 0

As root:

chmod 755 /etc/rc.d/init.d/postgresql

Test that it stops OK:

service postgresql stop

Now make it start and stop automatically:

chkconfig --add postgresql chkconfig --level 345 postgresql on chkconfig --list postgresql service postgresql start