I was warned:
<Jax> just use 8.3 except if you really need features of 8.4 <Jax> looks like postgis 1.4.1 was just release 17. dec.. <Jax> so you might be lucky
The recommended thing to do here would be to just install 8.3 if I want GeoDjango today on this relatively new install of ubuntu. This would, in ubuntu 8.10 and 9.04 (iirc), be as simple as:
$ sudo apt-get install binutils libgdal1-1.5.0 postgresql-8.3-postgis postgresql-server-dev-8.3 python-psycopg2 python-setuptools
But, we aren't the kind of folks who run something older than the latest stable release if we can get away with it. Karmic Koala (ubuntu 9.10) wants to install postgres-8.4 by default with:
$ sudo apt-get install postgres
However, if we try the same thing with postgis, sudo apt-get install postgis we get a version of postgis that doesn't support 8.4 (?).
Let's grab the latest version of postgis and get it working with the default install of postgresql-8.4. In a directory of your choosing, run commands not unlike the following (you may be able to get a later and greater version):
$ wget http://postgis.refractions.net/download/postgis-1.4.1.tar.gz
$ tar xvzf postgis-1.4.1.tar.gz
Check with the documentation. We need to install proj4 and gdal first:
$ sudo apt-get install proj-bin libproj-dev gdal-bin # python-gdal if you want
You will need the -dev packages:
sudo apt-get install postgresql-server-dev-8.4 libgdal-dev libgeos-dev
If you don't already have the tools, you might want to sudo apt-get install build-essential.
If you want the fancy LaTeX docs (and have an extra ~202MB of space to install LaTeX), you can:
sudo apt-get install dblatex
I'm a big fan of LaTeX so I'm going to go for it. We're almost ready to install postgis from source. But, let's not be hasty and just ./configure, make and make install. We're on the indomitable debian-based ubuntu, so let's use it's facilities and install a program called checkinstall that will allow us to uninstall and update with the standard package manager tools. sudo apt-get install checkinstall. Now we are ready.
Don't forget to take a look at the nice README provided by postgis. It says to run the make, make install as the postgres user. I don't think this is possible on ubuntu? At any rate, I ran checkinstall with sudo and it appears to work.
(As postgres or another privileged user?):
./configure make sudo checkinstall -D
Now you should be able to follow the instructions here to create the database template. Or uninstall with apt at your leisure.
You may need to install the psycopg database adapter which can be done with: sudo aptitude install python-psycopg2.
How you handle your permissions is your business, but you should be able to:
createdb -T template_postgis <database_name>
with a permitted user and then login with permitted user to create magical geospatial fields in your database.
That wasn't so bad.
you may need to:
sudo apt-get install libxml2-dev
if the libxml2-config can not be found (applies to postgis-1.5.0 but not postgis-1.4.1?)
The package manager version of GEOS is 3.1.0 and postgis 1.5.0 requires 3.1.1 so no dice unless you want to compile GEOS instead of installing with apt:
checking GEOS version... 3.1.0 configure: error: PostGIS requires GEOS >= 3.1.1