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:
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:
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 127.0.0.1. 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 192.168.1.0/24 add the following line in pg_hba.conf
host all all 192.168.1.0/24 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.