Install PostgreSQL server.

# pkg ins postgresql96-server # echo 'postgresql_enable="YES"' >> /etc/rc.conf

Load configuration of PostgreSQL server.

# service postgresql initdb

Setup PostgreSQL server.

# vi /var/db/postgres/data96/postgresql.conf

Allow access from all ip.

listen_addresses = '*'

Setup logging.

Find and comment parameter

#log_destination = 'syslog'

Uncomment and enable parameter

logging_collector = on

Also uncomment and change 2 parameters

log_directory = '/var/log' log_file = 'postgres.log'

Uncomment and change next parameters.

log_connections = on log_disconnectons = on log_line_prefix = '%t'

Also you may to setup your individual parameters of logging.

Create log.

# touch /var/log/postgres.log # chmod a+w /var/log/postgres.log

Start postgresql.

# service postgresql start

Connect to base.

# su - postgres # psql template1

Create password for user postgres.

# \password postgres # \q # exit

Enable authentication.

# vi /var/db/postgres/data96/pg_hba.conf

Go to the end of file and change parameters for local and ipv4, from trust to md5.
Comment ipv6 if you don't be use it.

Also add your subnet.

host all all md5

Restart PostgreSQL server.

# service postgresql restart