This page in other versions: 9.1 / 9.2 / 9.3 / 9.4 / current (9.5)  |  Development versions: devel  |  Unsupported versions: 7.1 / 7.2 / 7.3 / 7.4 / 8.0 / 8.1 / 8.2 / 8.3 / 8.4 / 9.0

Chapter 14. Installation Instructions

This chapter describes the installation of PostgreSQL from the source code distribution. (If you are installing a pre-packaged distribution, such as an RPM or Debian package, ignore this chapter and read the packager's instructions instead.)

14.1. Short Version

gmake install
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test

The long version is the rest of this chapter.


March 22, 2005, 2:34 a.m.

How to do it in FreeBSD:

$ su
# cd /usr/ports/databases/postgresqlXX-server/ (replace XX with the version number)
# make install


# cd /usr/local/pgsql/
# mkdir data
# chown pgsql data
# su - pgsql
$ /usr/local/bin/initdb -D /usr/local/pgsql/data
$ /usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
$ /usr/local/bin/createdb test
$ /usr/local/bin/psql test


April 1, 2005, 11:25 p.m.

The ODBC driver has been moved out of the PostgreSQL tree into a separate package. To get the ODBC driver code go to

April 9, 2005, 8:52 a.m.

How to do it in Gentoo:

$ su
# emerge postgresql


# cd /var/lib/postgresql/
# mkdir data
# chown postgres data
# su - postgres
$ /usr/local/bin/initdb -D /usr/local/pgsql/data
$ cd /var/lib/postgresql/data/
$ pg_ctl start -D /var/lib/postgresql/data/ -l logfile
$ /usr/local/bin/createdb test
$ /usr/local/bin/psql test

For more infos:

HOWTO Configure Postgresql in Gentoo

April 18, 2005, 9:36 p.m.

On (Open)Darwin you can use DarwinPorts ( ) to install PostgreSQL8. After installing the port system itself (see: ) you just type:

sudo port install postgresql8

Then you can add a user,
- on Mac OS X using NetInfo Manager (the easiest way to do this is to make a copy of the already existing mysql user and change this afterwards: choose a free uid and gid (I took 73) set the shell to some shell (for instance /bin/sh and the home to /usr/local/pgsql.

- If you're on OpenDarwin, you can use some of the available adduser scripts on the net ( for instance: download from rename it to .tgz instead of .bin, unpack it, check it with a text editor, change permissions to make it executable, run it).

the rest is pretty much the same, you just have to change every "/usr/local/pgsql/" into "/opt/local" (this is the default location where darwinports installs everything) or whatever prefix you've chosen for darwinports. initdb f.i. resides here by default: /opt/local/bin/initdb . I think you get the idea.

June 2, 2005, 2:25 p.m.

On CentOS4 (RHES-4) use:

rather than:

July 4, 2005, noon

Using darwinports on OS X: install with the server variant and a user named postgresql8 is automatically created.

sudo port install postgresql8 +server

this will install everything under /opt/local

July 13, 2005, 8:55 a.m.

The previous comment on how to do it in FreeBSD is not the usual way.

# su
# cd /usr/ports/databases/postgresql80-server/
# make install
As you wish add clean or distclean to the previous line.

Obviously creating the required folders and starting postgresql as the pgsql user should be left to the scripts provided by the port.

# echo "postgresql_enable=\"YES\"" >> /etc/rc.conf
# /usr/local/etc/rc.d/ initdb

To start it without doing a reboot
# /usr/local/etc/rc.d/ start

To create a database
# createdb mydb -U pgsql -O pgsql

Aug. 7, 2005, 7:35 p.m.

In Debian the following packages are necessary.


Sept. 11, 2005, 10:17 p.m.

Redhat 7.3. mucho frustration with Readline:

Not sure what the magic bullet was, but I installed:


before config would get all the way through. I also added refs to the libs but I think the above was probably all it needed.

Sept. 30, 2005, 4 a.m.

How to do it in debian:
#apt-get install postgresql
{wait and choose pg_data path}
//thats all!

Oct. 1, 2005, 7:46 p.m.

Correction in debian install. You can't install PostgreSQL 8 in Debian Sarge (current stable) with default apt-get configuration. Instead It will install version 7.4.x.

(If you are beginner Debian user, don't try apt-get to install newest version. Compile it from sources)

May 6, 2006, 3:15 a.m.

Compiling from source worked fine for me on Sarge with postgresql-8.1.3.

Additional installs:



create a link from make to gmake

Privacy Policy | About PostgreSQL
Copyright © 1996-2016 The PostgreSQL Global Development Group