The steps that I followed to compile, install and configure PostgreSQL 8.4.4 on Mac OS X 10.5.8 with Xcode 3.1.1.

The following is based on the excellent instructions which can be found at Working Software. Note: the version of Xcode that you have installed is important because Xcode contains files which are needed during the compilation process.

Create a postgres user.

$ sudo dscl . -create /Users/postgres UniqueID 174
$ sudo dscl . -create /Users/postgres PrimaryGroupID 174
$ sudo dscl . -create /Users/postgres HomeDirectory /usr/local/pgsql
$ sudo dscl . -create /Users/postgres NFSHomeDirectory /usr/local/pgsql
$ sudo dscl . -create /Users/postgres UserShell /usr/bin/false
$ sudo dscl . -create /Users/postgres RealName "PostgreSQL Administrator"
$ sudo dscl . -create /Users/postgres Password \*
$ dscl . -read /Users/postgres
dsAttrTypeNative:_writers_hint: postgres
dsAttrTypeNative:_writers_jpegphoto: postgres
dsAttrTypeNative:_writers_LinkedIdentity: postgres
dsAttrTypeNative:_writers_picture: postgres
AppleMetaNodeLocation: /Local/Default
GeneratedUID: BDC25B1D-32DC-4666-80E7-2FBF781A46D6
HomeDirectory: /usr/local/pgsql
NFSHomeDirectory: /usr/local/var/db/postgresql84
Password: *
PrimaryGroupID: 174
PostgreSQL Administrator
RecordName: postgres
RecordType: dsRecTypeStandard:Users
UniqueID: 174
UserShell: /usr/bin/false

Create a postgres group.

$ sudo dscl . -create /Groups/postgres PrimaryGroupID 174
$ sudo dscl . -create /Groups/postgres Password \*
$ dscl . -read /Groups/postgres
AppleMetaNodeLocation: /Local/Default
GeneratedUID: 8602505B-6167-4639-BC32-44552FE4E972
Password: *
PrimaryGroupID: 174
RealName: postgres
RecordName: postgres
RecordType: dsRecTypeStandard:Groups

Build and install PostgreSQL.

Download the code of the desired version (I used 8.4.4) from the PostgreSQL file browser and untar it somewhere.

$ cd postgres-8.4.4
$ ./configure --with-bonjour
$ make

Produces LOTS of output, followed by the all important:

All of PostgreSQL successfully made. Ready to install.

Now we can install:

$ sudo make install

This should also be followed by LOTS of output and then:

PostgreSQL installation complete.

Create a directory to hold the PostgreSQL database

$ sudo mkdir /usr/local/pgsql/data
$ sudo chown postgres:postgres /usr/local/pgsql/data
$ ls -lart /usr/local/pgsql/data

Create the initial database structure

$ sudo -u postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

This should end with something like:

Success. You can now start the database server using:

    /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
    /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

Configure PostgreSQL.

You can now decide how you would like to configure the day to day operation of PostgreSQL (for example, access control or logging) by using the *.conf files in the data directory that we just created.

You may also want to configure a launchd script to automatically startup PostgreSQL when the OS starts up and add the PostgreSQL executables to your PATH.

Some examples of how to do all this can be found in the Working Software article.

Filed under: tools


There are no comments.