Ubuntu 11.10 comes with PostgreSQL 8.4.
I did this downgrade because my web application, Hospital Management System, was developed using PostgreSQL 8.2 database and it will throw SQL query error if running on version 8.4.
This is step by step guide how to install PostgreSQL 8.2 on Ubuntu 11.10
1.Download source code from http://www.postgresql.org/ftp/source/ and extract it.
$ wget http://ftp.postgresql.org/pub/source/v8.2.19/postgresql-8.2.19.tar.gz $ tar zxvf postgresql-8.2.19.tar.gz
2. Configure, compile, and install
$ cd postgresql-8.2.19 $ ./configure --without-readline --without-zlib $ make $ su $ make install
3. Create postgres user
$ sudo adduser postgres
4. Create user data
$ sudo mkdir /usr/local/pgsql/data $ sudo chown postgres /usr/local/pgsql/data
5. Initialize database
$ su - postgres $ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
6. Edit PostgreSQL configuration file
$ sudo nano /usr/local/pgsql/data/postgresql.conf
And uncomment this line:
listen_addresses = 'localhost'
7. Run PostgreSQL
$ /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data &
8. Create test database
$ /usr/local/pgsql/bin/createdb test $ /usr/local/pgsql/bin/psql test
9. Don’t forget to install php pgsql module
$ sudo apt-get install php5-pgsql
10. Reload apache
$ sudo /etc/init.d/apache reload