Last change: 2005/8/26
PostgreSQL version: 8.0.3
postgresql.org
PostGIS version: 1.0.3
refractions.net
GRASS doesn't actually use PostGIS, but it's a good alternative to shapefiles for use in MapServer.
Note: If you are upgrading Postgres or PostGIS, stop Postgres first. In a Terminal (assuming you have it running under an install with these instructions):
$ su - postgres -c '/usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data'
In a Terminal type:
$ cd path_to_folder_containing_postgresql_source.tar.gz
$ tar -zxf postgresql-8.0.3.tar.gz
$ cd postgresql-8.0.3
If you are building with a GCC version below 3.3 (use 'gcc_select' to find out), you shouldn't unless you are on Mac OS 10.2, you may need to add -lstdc++
to LDFLAGS. Otherwise you will get a link error in PostGIS after PostgreSQL succeeds. Like so:
$ export LDFLAGS=-lstdc++
and continue:
% ./configure --without-readline --with-openssl --with-pam --with-krb5 --with-perl --enable-thread-safety
% make
% sudo make install
$ cd path_to_folder_containing_postgis_source.tar.gz
$ tar -zxf postgis-1.0.3.tar.gz
A couple patches to do. First, a config patch, edit makefile.config
. Edit the PROJ and GEOS sections so that the USE_XXXX is 1 and the XXXX_DIR is /usr/local. Also change USE_ICONV to 1.
Then, ICONV linking needs an adjustment. Edit loader/makefile
. Change the CFLAGS line in the USE_ICONV block to:
override CFLAGS += -DUSE_ICONV -liconv
$ cd postgis-1.0.3
$ export PGSQL_SRC=path_to_postgresql_source
$ make
$ sudo make install
Drag-n-drop the PostgreSQL source folder to set PGSQL_SRC.
Clean up the environment:
$ unset LDFLAGS
$ unset PGSQL_SRC
The first time you install PostgreSQL, you need to setup a few things. First, check that you don't already have a Postgres user:
$ sudo nidump -r /name=users/name=postgres /
If nothing is returned, do this:
$ echo 'postgres::72:72::0:0:PostGreSQL Database Server:/var/empty:/bin/sh' | sudo niload -v passwd /
$ sudo nidump -r /name=users/name=postgres /
Now, setup the data and log folders:
$ sudo mkdir /usr/local/pgsql/data
$ sudo chown postgres:postgres /usr/local/pgsql/data
$ sudo su - postgres -c "/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data"
$ sudo mkdir /usr/local/pgsql/var
$ sudo chown postgres:postgres /usr/local/pgsql/var
PostgreSQL is started by:
$ sudo su - postgres -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l /usr/local/pgsql/var/logfile -o -i'
Or you can get a Postgres startupitem from kyngchaos.com.