picture of Kevin Kemp
I have read several posts and noticed the large number of questions about Postgres so I decided to start from the beginning on how to get a PostgreSQL Database up and running. I am also going to try to cover some of the most common questions about startup and configuration.
I will be making the following assumptions about your system setup:
1) You have Redhat 7.0 installed
2) PostgreSQL is not currently installed
3) You have Gnome installed (I like Gnome)
4) You have linuxconf installed
5) You have root privileges
The items I will be covering include:
1) Installation of PostgreSQL Server and Client
2) The Postmaster configuration and option descriptions
3) User and Database Creation locally
4) Access from another computer

Step 1: Use CD's or Download files from the Redhat site or a mirror site

1) Required Files:
A) postgresql-server-7.0.2-17.i386.rpm
B) postgresql-7.0.2-17.i386.rpm
C) php-pgsql-4.0.1pl2-9.i386.rpm
2) Optional Files:
A) postgresql-devel-7.0.2-17.i386.rpm
B) postgresql-jdbc-7.0.2-17.i386.rpm
C) postgresql-odbc-7.0.2-17.i386.rpm
D) postgresql-perl-7.0.2-17.i386.rpm
E) postgresql-python-7.0.2-17.i386.rpm
F) postgresql-tcl-7.0.2-17.i386.rpm (I highly recommend this)
G) postgresql-tk-7.0.2-17.i386.rpm (This is part of the above)
H) phpPgAdmin_2-2-1-pl1.tar.gz (Download from http://www.greatbridge.org/project/phppgadmin/projdisplay.php)

Step 2: Install the files

1) Use GnoRPM or command line rpm -i to all of the .rpm files
2) Move phpPgAmin to the desired Folder. (I like the directory /Programming/phpprogs)
3) At a command line type tar -xzf phpPgAdmin_2-2-1-pl1.tar.gz
Step 3: Postmaster and Options
Postmaster has several options that I will give a brief description of:
1) -B = Sets the number of shared-memory disk buffers (Must be at least 2 times as many as the number of server processes). Each buffer is 8k of memory.
2) -D = Specifies the database directory
3) -N = Sets the max number of Postgres server processes
4) -S = Starts the postmaster in silent mode (No debug information)
5) -d = Debug Level
6) -i = Opens a TCP/IP port for remote connections
7) -l = Enables secured connections using SSL
8) -o = options passed to the server processes
9) -p = Specifies the TCP/IP port to open by option -i

Step 4: Start PostgreSQL

1) At the command line type linuxconf
2) Click on the control tab
3) Expand the control panel and click on control service activity
4) Scroll down until you find postgresql and click on it
5) Click on start
6) It should say it is running if all went well
7) Close linuxconf
Go to the directory /var/lib/pgsql/data. You will find a file named postmaster.opts.
This file indicates the options currently in use by the Postmaster. It should look something like this:
-p 5432
-D /var/lib/pgsql/data
-B 64
-b /usr/bin/postgres
-N 32
I have found that 32 server processes just isn't enough and I will be changing this to 128. I will also be changing the buffers to 512, which gives me 4M of buffer space. To make this change happen on the next start or restart of postgres the file named postmaster.opts.default needs to be edited. This is in the directory /var/lib/pgsql/data. It should look something like this:
I am going to change it to be:
-B 512 -i -N 128
Go back to the beginning of Step 4 and restart postgres. Look at the file postmaster.opts again. It now should look something like this:
-p 5432
-D /var/lib/pgsql/data
-B 512
-b /usr/bin/postgres
-N 128
If it doesn't then something went wrong. I haven't found a need to change any of the other options.

Step 5: Getting PostgreSQL to start on reboot

1) At the command line type linuxconf
2) Click on the control tab
3) Expand the control panel and click on control service activity
4) Scroll down until you find PostgreSQL and click on it
5) Click on the run levels tab
6) Click on Level 2, 3, and 5
7) Click on the Basic info tab and click on automatic
8) Click on accept and quit linuxconf
9) PostgreSQL should now start up automatically on reboot.

Step 6: Creating Users and Databases

1) At the command prompt type su postgres
2) To create a user type createuser phpuser (phpuser is the user to be created) You will be asked whether this user can create databases and users. For this example say yes to both.
3) To create a database type createdb phpdb (phpdb is the database to be created)
4) Type exit to leave the postgres user command prompt
5) To log into the newly created database. Type in psql phpdb -U phpuser (This connects us to the phpdb database as user phpuser)
6) Type in \q to log out of the database

Step 7: Access configuration to allow remote computer connections

1) In this example I want to allow all users from the computer with the ip address of to access all of the databases.
2) To do this I need to edit the pg_hba.conf file
3) It is in the directory /var/lib/pgsql/data
4) I will open this to be edited (This file is well documented so I will be brief here)
5) At the end of the file I am going to add a line that looks like this:
host    all   trust
I highly recommend setting passwords for access to any database and setting passwords for any of the users that may be created, most importantly any user that has rights to create other users as this user has access to the entire postgres system. This includes the user postgres. This could be devistating to your system as postgres can run C programs as procedures. Do I need to say any more?
I hope that this write up has been helpful. If there is enough interest in setting up postgres for Windows I will write up how to get it running.
-- Kevin