04 December 2010

Install PostgreSQL 9 on Ubuntu Linux

Tested on: Ubuntu 10.04

Add Repo

sudo nano /etc/apt/sources.list

Append lines:

## Postgres 9 hasn't been backported yet.  Manually added repos.
deb http://ppa.launchpad.net/pitti/postgresql/ubuntu lucid main 
deb-src http://ppa.launchpad.net/pitti/postgresql/ubuntu lucid main

Go to this site and expand the "Technical details about this PPA" panel. Under Signing Key, copy everything to the right of the slash [/], and paste into the command below. In this example, it is "8683D8A2".

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8683D8A2
apt-get update

Remove Old Versions

Careful! These commands completely remove your old PostgreSQL version. Back up data first.

sudo service postgresql-8.4 stop
sudo apt-get purge postgresql*

Install

sudo apt-get install postgresql-9.0

Verify you can log in:

sudo -u postgres psql

You probably want to create a user for your web app while you're in there:

CREATE USER www_db WITH PASSWORD 'jw8s0F49eQ';

Open External Access

If you plan to access Postgres externally, modify conf file to make Postgres listen on * instead of localhost. Modify Host-Based Authentication file to make Postgres respond to more IP ranges than solely 127.0.0.1. See my other article on this.

Instrumentation

So pgAdmin doesn't complain:

apt-get install postgresql-contrib-9.0
sudo -u postgres psql -U postgres -d postgres < /usr/share/postgresql/9.0/contrib/adminpack.sql

Filed under Linux

Archives