Monday, November 5, 2012

Postgres : Server Installation and settings

Postgres is one of the popular database server for Ruby on Rails Applications. This post takes us step by step, installation and some important settings.

Postgres 9.1.x installation steps
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql
This will install the postgresql to the server/ your local machine. If you just want to use it locally then these steps are enough. But if you also want to use this database available for other machines then you have to add the ip to pg_hba.conf for making availablity for that ip machine only.
There is also other option for making database available if your ip is not stable. which is as given below. But also suggested use this only if server is only for internal use. For this we need to make following changes in

/etc/postgresql/9.1/main/pg_hba.conf(find following and make changes as shown)
# TYPE  DATABASE     USER  ADDRESS        METHOD
  local all          all                  trust
  host  all          all   127.0.0.1/32   trust
And another to the same file
# IPv4 local connections:

# host  all          all   127.0.0.1/32   md5
  host  all          all   0.0.0.0/0      trust
other file to make changes is /etc/postgresql/9.1/main/postgresql.conf
port = 5432
listen_addresses = '*'
And then just restart the server.
sudo /etc/init.d/postgresql restart
Install pgAdmin3
sudo apt-add-repository ppa:flexiondotorg/postgres
sudo apt-get update
sudo apt-get install pgadmin3

No comments:

Post a Comment