PostgreSQL Database

A compatible version of PostgreSQL must be installed and configured for access by the Æmail user(s).  The primary site for official Postgres releases is http://www.postgresql.org/.

Please follow the official PostgreSql documentation to get the database installed, configured, and bootstrapped.  The instructions below are only for clarification.

Server configuration

All Æmail data can be regenerated in the event of database corruption.  If no other data are being stored in the database and the system is not subject to crashes, database performance can be improved significantly by turning off synchronous writes in data/postgresql.conf:

Centrally administered Postgres

If a separate account serves as Postgres superuser as is recommended in the Postgres documentation, then the following steps are needed allow normal use of the database from account myacct.  These should all be done by user postgres:

  1. Initialize:  initdb -D /usr/local/pgsql/data
  2. Start the postmaster process:  nohup /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >& /var/log/postgres < /dev/null & (after creating /var/log/postgres with appropriate permissions)
  3. Grant access to myacct:  createuser -s myacct

To avoid problems with stale sockets being left over from killed Postgres processes, the following commands should be used in rc.local to restart Postgres on each reboot:

echo "Starting postgres..."
rm -f /tmp/.s.PGSQL.*
su postgres -c "nohup /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >& /var/log/postgres < /dev/null &"

Postgres in a user account

Postgres is normally installed with the assistance of the system administrator in a separate postgres account.  However, it is possible to install it in any user account without system administrator support.

When running the configure script as described in the INSTALL file, you must specify an accessible install directory: ./configure --prefix=/home/myacct/pgsql (substitute your own username for myacct).

After this setup has been done, it is only necessary to ensure that the postmaster process is running to continue using the database.  This can be accomplished by manually restarting it after each reboot or by installing a cron job to keep it running.

Privacy of data

Access to all Postgres databases is controlled by editing the files data/pg_hba.conf and data/postgresql.conf.  The default configuration denies access from anywhere but the local host.  However, other users on the same host are still able to access your data.  The degree to which access can be controlled depends on the authentication services provided by your system.  Refer to the Postgres documentation and the comments in pg_hba.conf and postgresql.conf for details on the available security mechanisms.

If you do not intend for other users to access the database at all, one simple way to improve security is to modify postgresql.conf to tighten the default socket permissions:


Back to "Installation and Configuration"

Home