PostGIS is a collection of GIS extensions for PostgreSQL. They can be found here:
Installation on Windows
Make certain that PostgreSQL is installed on your machine, and that the PostGIS extensions were not installed as part of the PostgreSQL installation. PostGIS is optional to install during the installation of PostgreSQL, but the version packaged with PostgreSQL is often several revisions behind the latest PostGIS releases. For installation of PostgreSQL, see PostgreSQL.
Run the PostGIS installer, install PostGIS as well as a spatial database. Call the spatial database ‘bootstrap’, as with PostgreSQL you need to connect to a database in order to do things such as DROP and CREATE other databases.
Installation on Linux
Unfortunately, the ‘fool-proof’ way to install PostGIS on Linux is to do it from sources. There are .rpms out there, but figuring out the dependencies can be an absolutely mind-numbing experience. Using sources is easier, and it works.
If PostgreSQL is already installed on your Linux machine, then download the appropriate PostgreSQL sources from here. Untar the sources to a directory where you have write and execute permissions.
If it is not installed, you can either install it from sources, or install it using your preferred linux install procedure (.rpm, .deb, apt, yum, etc.). See PostgreSQL
Download the sources for PostGIS here. Untar the sources into the contribdirectory of the source structure of PostgreSQL.
Do a make of the PostgreSQL sources to create the headers:
#> ./configure #> make
Go into the contrib/postgis-#.#.# directory and do the following:
#> cd contrib/postgis-#.#.# #> ./configure #> make #> make install
Create the ‘bootstrap’ database as a spatially-enabled database:
#> service postgresql start #> su postgres #> createdb bootstrap #> createlang plpgsql bootstrap #> psql -d bootstrap -f lwpostgis.sql #> psql -d bootstrap -f spatial_ref_sys.sql
Creating a PostGIS enabled database
There are two ways to create a spatially-enabled database: using SQL or through the command-line.
Create a Spatially-Enabled Database using SQL
Use the following SQL statement:
create database ontrace template=template_postgis
Create a Spatially-Enabled Database from the Command-Line
Use the following commands:
#> createdb yourDatabase #> createlang plpgsql yourDatabase #> psql -d yourDatabase -f lwpostgis.sql #> psql -d yourDatabase -f spatial_ref_sys.sql