Installing & Configuring Postgres on Ubuntu 14.04

In this tutorial, we will walk through the steps required to install and configure Postgres for your Greenfield application.

This tutorial assumes you have already created an Ubuntu 14.04 x64 VPS instance and have installed and configured Apache & Tomcat. If you haven't done this already, follow Minimum Server Setup : Apache, Tomcat & Greenfield on Ubuntu 14.04 for detailed instructions on how to install and configure Apache & Tomcat for Greenfield

1. Install Postgres

sudo apt-get install postgresql postgresql-contrib

2. Update Postgres user password

You will want to update the postgres user password after initial install

Switch to postgres user

sudo -i -u postgres

Invoke psql command line


Change password

alter user postgres with password 'new password';

Exit out of psql


3. Configure Postgres to accept outside connections (optional)

Depending on what type of user you are, you may want to configure postgres to accept connections from outside the server. One reason to do this is to use pgAdmin on your local machine. So in the example I will configure Postgres to accept connections from a personal machine/ip address

Login as postgres user

sudo -i -u postgres

Edit postgresql.conf

vim /etc/postgresql/9.3/main/postgresql.conf

Add/Edit the following listen_addresses definition to look like this


Edit pg_hba.conf to allow connections from your ip address

vim /etc/postgresql/9.3/main/pg_hba.conf

Add following line

substitue your ip address for listed in example

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             all                md5

Restart Postgres

/etc/init.d/postgresql stop
/etc/init.d/postgresql start

Download/Install pgAdmin

Now that you have Postgres installed and configured for an outside connection, you can download pgAdmin then create your Greenfield database. If you are new to pgAdmin, it is a Postgres database management GUI interface which simplifies database administration