First lets do an update before we start installing PostgreSQL
$ yum update
You can install PostgreSQL from CentOS Base repo or can do a search for the latest version and install it based on your needs. Method 1 describes manual setup and Method 2 indicates an install from CentOS base repo
METHOD 1: Manual setup of PostgreSQL
$ vi /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever – Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
exclude=postgresql*
#released updates
[updates]
name=CentOS-$releasever – Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
exclude=postgresql*
Go to http://yum.postgresql.org/repopackages.php and check out for the version of PostgreSQL depending on your OS.
Repo URI for CentOS at the time of writing this tutorial: http://yum.postgresql.org/8.4/redhat/rhel-5-i386/pgdg-centos-8.4-3.noarch.rpm
Now, change to your home directory and install PostgreSQL
$ cd ~
$ curl -O http://yum.postgresql.org/8.4/redhat/rhel-5-i386/pgdg-centos-8.4-3.noarch.rpm
$ rpm -ivh pgdg*
METHOD 2: Install from CentOS base repo
$ yum install postgresql84 postgresql84-server postgresql84-contrib
Initialise the service
$ service postgresql initdb
## OR ##
/etc/init.d/postgresql initdb
Set the runlevel
$ chkconfig postgresql-8.4 on
Start the database service
$ service postgresql-8.4 start
To make modifications of PostgreSQL configuration, go to
$vi /var/lib/pgsql/8.4/data/postgresql.conf
Some of the most common changes that can be made related to PostgreSQL are listening IP address and port
listen_address = ”
port 5432