3.5. Configuring the Database (PostgreSQL)

3.5.1. Initialization of PostgreSQL

In some distributions, PostgreSQL database cluster is not initialised. Consult distribution documentation for more information. If database cluster is not created, you can do so by running:

# su - postgres
$ initdb

Caution

This will wipe out any existing PostgreSQL databases!

3.5.2. PostgreSQL Authentication Configuration

The postgres PostgreSQL user is used only during installation. Usually, it can connect via UNIX socket without password when invoked by postgresql system account. Check by running this:

# su - postgres
$ psql template1

If connection fails, add the following line to pg_hba.conf:

local all postgres ident sameuser

GForge uses gforge PostgreSQL user to connect to gforge database by using password. (You can change that name by editing local.inc.) In order this to work, assure that you have the following line in your pg_hba.conf (before other host directives):

host gforge gforge 127.0.0.1 255.255.255.255 md5

This line assumes that GForge will always use local PostgreSQL database (localhost). If this is not the case, consult PostgreSQL manual for ways to allow connection.

The following option should be set in postgresql.conf because connection to localhost uses TCP/IP:

tcpip_socket = true

After all these changes to PostgreSQL configuration files are made, PostgreSQL should be restarted. This depends on the distribution. In Debian, it's like this:

# /etc/init.d/postgresql restart

3.5.3. Importing Database

Create GForge database user:

# su - postgres
$ psql template1
template1=# CREATE USER gforge NOCREATEUSER NOCREATEDB
template1-# PASSWORD 'gforge-password';

Create GForge database:

template1=# CREATE DATABASE gforge OWNER gforge ENCODING 'UNICODE';

Add PL/pgSQL support using the commands:

# su - postgres
$ createlang plpgsql gforge

Finally, install the database:

$ cd /var/www/gforge/db
$ psql -a -U gforge -W -h localhost -f gforge.sql gforge &> /tmp/gforge.sql.log

Note

You may experience the following errors. They are harmless and you can safely ignore them:

ERROR:  permission denied for language c
ERROR:  must be superuser to create procedural language
ERROR:  permission denied for schema public