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 “sudo -s
“.
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
gmake
gmake install
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…..
mkdir /usr/local/pgsql/data
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)….
export PGDATA=/usr/local/pgsql/data
export PATH=$PATH:/usr/local/pgsql/bin
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…..
pg_ctl stop
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.
While at it here are the steps for compiling Perl on Tiger (download & unzip source first).
As “root”…
sh Configure
gmake
gmake test
gmake install-all
Only difference is the “install-all”, which is recommended for MacOSX.