Install PostgreSQL 8.4 on CentOS

Posted on Sun 15 May 2011 in PostgreSQL

This tutorial explains a basic configuration using PostgreSQL and CentOS. For detailed information about configuration parameter please read the PostgreSQL documentation which is very good organized.

First thing you should do is updating your system to the last patch level. Be sure all the other installed software on this system works with the newest patches and then simply update your CentOS with:

yum update

Now reboot and install PostgreSQL. I prefer the 8.4 version on CentOS as long as there is no newer stable one which is delivered via the official repository.

yum install postgresql84-server

Before the first start the database needs to be initialized with the following command:

service postgresql initdb

The output looks like this:

postgresql initdb output

Start the service:

service postgresql start

and add it to your runlevel:

chkconfig --level 35 postgresql on

Now PostgreSQL is installed and running. Per default PostgreSQL data directory is located in /var/lib/pgsql/data. With no changes PostgreSQL service is only listening to localhost and is bound to This is not practical if you plan to run database and application on different hosts via network connection.


To allow for example connections from your private network add the following line in pg_hba.conf

host all all trust

and change or add the following line in /var/lib/pgsql/data/postgresql.conf

listen_addresses = '*'

The database needs to be restarted after changing this files.

service postgresql restart

Be sure you only allow access to your database for hosts which really need it.