If these instructions are followed carefully with Ubuntu Heron, at the time of writing, you will get PostGIS running with QGIS in a few minutes.
These instructions are now out of date.
Use these to install in the latest version of Ubuntu
First place the following in your sources list either using synaptics or pasting the line at the bottom of /etc/apt/sources.list (sudo gedit /etc/apt/sources.list)
deb http://ppa.launchpad.net/qgis/ubuntu hardy main
sudo apt-get update
sudo apt-get install qgis
sudo apt-get install postgresql-8.3
sudo apt-get install postgis
sudo apt-get install postgresql-8.3-postgis
sudo apt-get install pgadmin3
One small step that is necessary is to change the user password for postgres within the database as for some reason after installing PostGIS it is no longer the default value “postgres” (Although the linux password for postgres is) . You can do this with psql. Care needed here. This has to be done correctly. The following line gets you into psql.
sudo -u postgres psql -d template1
Type this (being very careful with quotation marks and the semicolon).
alter user postgres with password ‘postgres’;
If successul you get a message saying ALTER ROLE (If there is any problem here then retype the single quotation marks to make sure they are simple. WordPress keeps changing them for some reason if they are not in an HTML box).
Then exit psql with \q or control d
Now create a database
sudo -u postgres createdb gisdb
Download a small test database with the countries of the word from this site with wget. Again the file is disguised as a word doc in order to go into the wordpress site.
Restore this database.
sudo -u postgres psql gisdb<paises.doc
Now run qgis and connect to your new PostGIS data base.
You can then experiment importing shapefiles into the database using the graphical plugin “SPIT” and looking at the structure of the database using pgadmin.
The trial database with a single countries of the world table can also be downloaded without wget by clicking here.