wiki:UsersWikiPostGIS21UbuntuPGSQL93Apt

Version 4 (modified by robe, 10 years ago) ( diff )

The PostgreSQL Apt Repository now hosts installs of PostGIS, in addition to Postgresql and PGAdmin3.

The following describes how to install Postgresql 9.3, PostGIS 2.1, PGAdmin 1.18.1 and shp2pgsql-gui on Ubuntu versions 12.04 through 13.10.

Add Respository to sources.list

Run in terminal:

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list'
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update

Install

The following will install postgresql 9.3, PostGIS, PGAdmin3, and additional supplied modules including adminpack

sudo apt-get install postgresql-9.3 postgresql-9.3-postgis pgadmin3 postgresql-contrib

Enable Adminpack

While in terminal, log in to psql as postgres user:

sudo -u postgres psql
CREATE EXTENSION adminpack;

Quit psql:

\q

Create new PGSQL user

You can create a new database super user to use instead of the default postgres user.

While in terminal, run:

sudo su - postgres
createuser -d -E -i -l -P -r -s yourUserName

(be sure to change the username to your desired username)

Enter your new password when prompted

Log out as postgres user:

exit

Exit terminal:

exit

Use PGAdmin to log into database server

From the Ubuntu launcher, type in PGAdmin to reveal the application

Click the Add a connection to server button on the menu in the top-left corner

Fill in the necessary credentials to log in:

- Name: nickname you want to give your connection
- host: localhost (until you change the connection settings)
- port: 5432 by default
- maintenance DB: postgres by default
- username: whatever you chose in the step above
- password: whatever you chose in the step above

Enable postgis extensions on new database

Since you installed PostgreSQL and PostGIS from the PostgreSQL apt repository, you now have all the extensions for PostgreSQL, including PostGIS

Expand the database tree in PGAdmin, and reveal the extensions node

Right-click the extensions node, and click new extension

Enable the postgis extension, as well as postgis_topology

Import SHP files using shp2pgsql-gui

Another handy piece of software shp2pgsql-gui tool. This will allow you to quickly connect to your new PostGIS database and import a Shapefile.

Open terminal, and type:

shp2pgsql-gui

Follow the on-screen prompts to load your data.

For more information, visit the Boston GIS tutorial in the section "Load Towns Data"

Note: See TracWiki for help on using the wiki.