Compiling PostgreSQL on Tiger
I’ve compiled Postgres many times on Linux and never had an issue… so fingers crossed it would be just as easy on MacOSX.
A good place to start is an article on Apple’s developers site…. Postgres on Mac OS X
However I’ll be using DarwinPorts (or MacPorts as its now known) instead of fink. In fact you may ask why don’t I just install the Darwin port of Postgres? When it comes to critical apps which are important to me I always prefer to use the source and therefore can apply any compilation settings that I may need.
Here’s the steps I went thru (via Terminal session). DarwinPorts being installed is a prerequisite….
First off u must become root. You can do this from an admin account with just “
Next we must install some ports that Postgres will need….
port install readline
port install gmake
port install bison
Then we need to create a /usr/local directory (
mkdir /usr/local). Within this we need a “src” directory where we can download the Postgres source code to (
cd /usr/local ; mkdir src ; cd src).
Download the latest stable PostgreSQL source from http://www.postgresql.org and unpack it….
gzcat postgres-source.tar.gz | tar xvf -
Now you in a position to compile the source code. Go into the Postgres directory that was unpacked and do the following steps….
./configure --with-includes=/opt/local/include/ --with-libraries=/opt/local/lib --with-bonjour
PostgreSQL as now been compiled and installed. Next step is to initiate the database storage area. For this you will need to create a “postgres” account on your Mac. (If unclear then read instructions in the article on how to do this). Then do this…..
chown postgres /usr/local/pgsql/data
su -l postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
We now have a fully working PostgreSQL RDBMS on your Mac.
Next you want to put the following in your login .profile (for the postgres account)….
If you now source this profile with you now have the Postgres commands in your $PATH (
. .profile ).
To start the Postgres DB server (postmaster) in the background….
pg_ctl -l logfile start
and to stop it…..
You can now go ahead and create a database in PostgreSQL.
That’s it for now but will touch on security & auto launching at later date.