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.


Jan. 9, 2006, 9:18 p.m.

If you are using macOS X and standard ./configure does not work and you use fink, try
./configure --with-includes=/sw/include --with-libraries=/sw/lib . This causes the installer to look at your fink installed packages as well.

Jan. 10, 2006, 7:38 p.m.

if "adduser" is not found, then use "useradd" for SUSE.

Feb. 3, 2006, 3:26 p.m.

If the ./configure script throws an error for readline lib;
Check if you have both readline & readline-devel installed. Try re-installing both. Check ncurses installation if it still fails.

March 6, 2006, 10 p.m.

On FreeBSD compilation process takes enormous amount of time, on Celeron 2.4Ghz, 512MB RAM, more than 2-3 hours, and even more.

March 12, 2006, 7:57 p.m.

If you install on FreeBSD with ports and end up here because you are looking for the initdb command you should realize that the default user from ports is pgsql not postgres and the programs are installed in /usr/local/bin not /usr/local/pgsql/bin/

April 12, 2006, 11:38 a.m.

As pointed out, on openSuse 10 you need to ensure that the readline & readline-devel libraries are properly installed,

I ended up ( after a fiar few ./configure problems ) having success with

rpm-Uvh --force --replacefiles readline-5.0-9.i586.rpm readline-devel-5.0-9.i586.rpm

I hope this is useful to some other poor soul ;)

April 20, 2006, 7:30 p.m.

If using Red Hat Linux Fedora Core (and probably other Red Hat versions), and you install from RPMs:

1) Your directory is /var/lib/pgsql instead of /usr/local/pgsql, and the binaries will be inserted into /usr/bin instead of /usr/local/pgsql/bin. Thus, all of the executables are already in the default BASH path as setup by a fresh installation.

2) I've never had to add the postgres user - already there.

3) Importantly, start, stop, restart with:

/sbin/service postgresql {start | stop | restart | (others?) }

This will put log messages in /var/lib/pgsql/pgstartup.log On the first run, it'll error out about this file - it's normal.

May 7, 2006, 10:54 a.m.

On Ubuntu, same thing as on Fedora if you install from DEBs.

May 7, 2006, 2:21 p.m.

If you read the notes on the FreeBSD source install above taking hours... Don't be scared off by that. Of course the easiest way is just to install from ports, but if you're a source nut its not a 3 hour process (of course that depends on your hardware). I built from source on a heavily loaded server with duel P3 600's - 512 RAM and it finished within 10 min from gmake to gmake install. I've tested the same thing on a single P3 500 and got similar results.

May 18, 2006, 4:27 p.m.

Don't forget to set the PGDATA environment variable to /var/lib/pgsql/data in the postgres user's .bash_profile. This avoids having to specify -D. Same for any user who will be allowed to connect to the server.

On FC5, if you start the postgresql daemon before running initdb, it will automatically initialise the database server for you. However, in pg_hba.conf it sets the default permissions to ident sameuser meaning that the database cannot be accessed properly. Edit the file, specify trust and restrat the server using pg_ctl. Then you can proceed to add users etc. Once that's done permissions can be set to md5 and the server can be restarted.

June 10, 2006, 8:31 p.m.

On FC5 to make the ident authentication work I had to remove the -E switch from the server_args line of /etc/xinetd.d/auth which disables the encryption of user names.

Aug. 29, 2006, 8:03 p.m.

built PostgreSQL 8.1.4 from source on OpenBSD in less than 12 min on a Dual PIII, you must install gmake from ports first no big deal

Sept. 9, 2006, 5:10 p.m.

The FreeBSD package only takes awhile if you don't have any of the other packages installed that it depends upon and what options you want installed when config runs for the package. Keep in mind that if you install all options and all dependant package options it will take awhile. A more accurate assessment of the compile time of the FreeBSD pgsql packages is after all dependancies have been installed then installing just the client and server packages. From make to installation was a couple of hrs on a dual P-II/300 with a RAID controller but that included all of the dependant packages plus the bells & whistles I specified to include when configure ran for the package and the respective dependant packages. When you make a port from the FreeBSD ports list, it will go out and compile everything you need for that port to work. A much welcome feature of the FreeBSD ports and packages collection.

Sept. 15, 2006, 8:31 p.m.

In order to increase the compilation speed slightly add a '-pipe' gcc option to CFLAGS variable.

Oct. 2, 2006, 6:12 p.m.

A bunch of regression tests failed on my OpenBSD installation. The culprit? I was compiling the code as a normal user, and OpenBSD sets lower limits for users than it does for root and daemon and staff accounts, in particular with respect to process, file, and stack limits. And "make check" is very resource intensive.

Try "ulimit -a" to list your limits, and compare those with root's. If you can't compile as root, modify login.conf and add a new login class. Set the compiling user's login class to that new login class using usermod.

Oct. 14, 2006, 5:27 p.m.

Explaination of 2>&1 n>&m: Swap Standard Output and Standard Error

How-To-Install and Linux Commands
For some practical install experience, please see the book "Practical PostgreSQL", Chapter 2. Installing PostgreSQL
Example 2-10. The gmake install command
$ su -c "gmake install"
Using the su -c command lets you save a step by only logging you in as the root user for the duration of the command’s execution.

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