Guide to compile and install PostGIS 2 on FreeBSD with PostgreSQL 9.2

[work in progress.]

Currently there is no PostGIS2 port, so you will have to compile directly from source.

Follow generic guide here:

FreeBSD specific guide:

Install/upgrade dependencies:

Check PostgreSQL installed

pkg_info | grep sql

Upgrade to PostgreSQL 9.2 [not needed as long as you have >9.0, but as this is a development server, I moved to 9.2]

pg_dumpall > dumpfilename.sql [have to be proper user]

/usr/local/etc/rc.d/postgresql stop

cd /usr/local/

mv pgsql pgsql_dump_date +%Y%m%d%H%M

pkg_delete postgresql91-contrib

pkg_delete postgresql91-client

pkg_delete postgresql91-server

cd /usr/ports/databases/postgresql92-server

make install clean [config as needed]

repeat for contrib

[see for better instructions on upgrading:]

Upgrade PGAdmin3 to 1.16 to work with PostgreSQL 9.2

Throws an error when port is compiled. I took the easy way and installed the newest PBI

Use 'pkg_info |grep gdal' to check for gdal, proj4, and other dependencies

Install/upgrade as required from ports

cd /usr/ports/graphics/gdal

make install clean .......



tar -xvzf postgis-2.0.7.tar.gz

cd postgis-2.0.7


First got iconv.h configuration errors. Tried to link to iconv work directories - no go. Use ./configure --with-... as in provided link.


$ make install

Go to PGAdmin3 -> database you want the spatial extensions on -> extensions -> add new extension -> choose postgis & postgis topology

Remember to have fun!


Last modified 3 years ago Last modified on Apr 6, 2015 4:25:02 PM