After compiling and installing PostgreSQL, we want to init the database, and want to start with some sane defaults.
Add the following to /etc/rc.conf
postgresql_initdb_flags="-D /usr/local/pgsql/data -W -A md5"
postgresql_enable="YES"
And then run:
mkdir -p /usr/local/pgsql/data
chown pgsql:pgsql /usr/local/pgsql/data
/usr/local/etc/rc.d/postgresql initdb
After this we need to modify a few files to get it to listen to TCP/IPv4 connections, first we start with postgresql.conf and add:
listen_addresses = '10.99.12.1'
Then in pg_hba.conf we add a new line:
host all all 10.99.12.0/24 md5
This allows anyone in the 10.99.12.0/24 range to connect to our PostgreSQL instance and to use the databases. This is exactly what we want to allow, now we start PostgreSQL using the rc script:
/usr/local/etc/rc.d/postgresql start