Text Size: Normal / Large

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

./configure
gmake
su
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.


User Comments


Alejandro Valenzuela <lanjoe9 AT hotmail.com>
22 Mar 2005 2:34:53

How to do it in FreeBSD:

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

{wait}

# 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

done.

ScriptHead <scripthead AT gmail.com>
01 Apr 2005 23:25:48

The ODBC driver has been moved out of the PostgreSQL tree into a separate package. To get the ODBC driver code go to http://www.postgresql.org/ftp/odbc/versions/src/

Marco Lazzeri <marcolz AT aliceposta.it>
09 Apr 2005 8:52:06

How to do it in Gentoo:


$ su
# emerge postgresql

{wait}

# 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
------------------------------------
http://gentoo-wiki.com/HOWTO_Configure_Postgresql

Lars <lars.sonchocky-helldorf AT hamburg.de>
18 Apr 2005 21:36:51

On (Open)Darwin you can use DarwinPorts ( http://darwinports.opendarwin.org/ ) to install PostgreSQL8. After installing the port system itself (see: http://darwinports.opendarwin.org/docs/ch01s03.html ) 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 http://www.opendarwin.org/pipermail/hackers/attachments/20040615/d29608ba/adduser.bin from http://www.opendarwin.org/pipermail/hackers/2004-June/004307.html 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.

James B. Bynre <byrnejb AT harte-lyne.ca>
02 Jun 2005 14:25:53

On CentOS4 (RHES-4) use:
/var/lib/pgsql/data

rather than:
/usr/local/pgsql/data

Wilkes Joiner <wilkesjoiner AT gmail.com>
04 Jul 2005 12:00:46

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

Dominic Fandrey <LoN_Kamikaze AT gmx.de>
13 Jul 2005 8:55:51

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/010.pgsql.sh initdb

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

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

Marcelo Santa Ana <marcelo.santaana AT gmail.com>
07 Aug 2005 19:35:43

In Debian the following packages are necessary.

libreadline4-dev
zlib1g-dev.

Stephen Dee <ala_frosty AT yahoo.com>
11 Sep 2005 22:17:34

Redhat 7.3. mucho frustration with Readline:

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

ncurses-devel
libtermcap-devel
readline-devel
zlib-devel

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.

javero <jonathan.root AT gmail.com>
30 Sep 2005 4:00:18

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

viitala <pjviit AT utu.fi>
01 Oct 2005 19:46:58

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)

Milan Mogin <milan AT dolithe.com>
06 May 2006 3:15:28

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

Additional installs:

libreadline4-dev
zlib1g-dev
termcap-compat

Tweeks:

create a link from make to gmake

Add Comment

Please use this form to add your own comments regarding your experience with particular features of PostgreSQL, clarifications of the documentation, or hints for other users. Please note, this is not a support forum, and your IP address will be logged. If you have a question or need help, please see the faq, try a mailing list, or join us on IRC. Note that submissions containing URLs or other keywords commonly found in 'spam' comments may be silently discarded. Please contact the webmaster if you think this is happening to you in error.

In order to submit a comment, you must have a community account.

* Comment
 

* denotes required field

Privacy Policy | Project hosted by hub.org | Designed by tinysofa
Copyright © 1996 – 2007 PostgreSQL Global Development Group