This chapter focuses on the requirements and steps involved in installing and configuring PostgreSQL. Many of the PostgreSQL capabilities are not enabled, by default. For example, support for the TCL language is a feature that must be explicitly requested during compile-time. As there are many other features that are not configured by default, we will cover the various flags and options you may use to enable them when compiling PostgreSQL. It is important that you carefully read through all the steps in this process before beginning installation.
This chapter will walk you through the installation steps on a Linux/UNIX-style platform. Our installation platform is Linux, but these instructions should be compatible with most current UNIX platforms.
Note: Although PostgreSQL is capable of running on a Win32 platform, this book does not cover installation on Windows. The Win32 version of PostgreSQL requires the Cygwin environment and will not operate independently within Win32. Although Cygwin can be useful in many situations, the use of PostgreSQL in a Cygwin environment is not recommended.
The installation of PostgreSQL is not difficult. However, there are some software requirements that you will need for the PostgreSQL compilation. All of the requirements — outside of the PostgreSQL source code — are GNU tools. If you are running Linux, there is a good chance that the tools are already installed. If you are running a BSD derivative, such as FreeBSD or MacOS X, you may have to download the tools.
If you find that you are missing any of the required components, first check your vendor's web site for the packages; otherwise, you may download them from http://www.gnu.org. It is also essential that you have enough disk space available to unpack and compile the source code on the filesystem to which you install. Disk-space requirements are discussed in the Section called Disk Space."
You will most likely have some of the required software packages already installed on your system, if not all of them. These packages are as follows:
GNU make is commonly known as gmake on non-GNU based systems, but is normally referred to as just make on GNU-based systems such as Linux. For consistency, we will refer to it as gmake throughout the rest of this book.
We recommend that you use at least gmake version 3.76.1 or higher when compiling PostgreSQL. To verify the existence and correct version number of gmake, type the command shown in Example 2-1.
Example 2-1. Verifying GNU make
$ gmake --version GNU Make version 3.79.1, by Richard Stallman and Roland McGrath. Built for i386-redhat-linux-gnu Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Report bugs to <firstname.lastname@example.org>.
There are numerous ISO/ANSI C compilers available. The recommended compiler for PostgreSQL is the GNU C Compiler, although PostgreSQL has been known to build with compilers from different vendors. At the time of this writing, the most commonly distributed versions of GCC are 2.95 and 2.96 (RedHat Linux 7.x and Mandrake Linux 8.x). If you do not currently have GCC installed, you can download it by visiting the GNU website at http://gcc.gnu.org.
To check for the existence and version of GCC, enter the command shown in Example 2-2.
GNU zip is also called gzip. GNU zip is a compression utility that can compress as well as decompress files. All compressed, or zipped, files made with gzip have a .gz extension. You can test for the existence of the gzip program with the gzip --version command.
In addition to gzip, you will require a copy of tar, a utility used to group several files and directories into a single archive, as well as to unpack these archives onto the filesystem. An archived tar output file will typically contain a .tar extension. Files that are both archived by tar and compressed by gzip often have a .tar.gz compound extension, as is the case with the included PostgreSQL source distribution. You can test for tar with the tar --version command.
Example 2-3. Verifying gzip and tar
$ gzip --version gzip 1.3 (1999-12-21) Copyright 1999 Free Software Foundation Copyright 1992-1993 Jean-loup Gailly This program comes with ABSOLUTELY NO WARRANTY. You may redistribute copies of this program under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING. Compilation options: DIRENT UTIME STDC_HEADERS HAVE_UNISTD_H HAVE_MEMORY_H HAVE_STRING_H Written by Jean-loup Gailly. $ tar --version tar (GNU tar) 1.13.17 Copyright 2000 Free Software Foundation, Inc. This program comes with NO WARRANTY, to the extent permitted by law. You may redistribute it under the terms of the GNU General Public License; see the file named COPYING for details. Written by John Gilmore and Jay Fenlason.
The following are some optional packages that you may want to have installed:
The GNU Readline library greatly increases the usability of psql, the standard PostgreSQL command-line console client. It adds all of the standard functionality of the GNU Readline library to the psql command line, such as being able to easily modify, edit, and retrieve command-history information with the arrow keys and the ability to search the command history (also known as a reverse-i-search). If the Readline library is already installed on your system, the configuration process should automatically compile readline support with psql.
Note: You may not need this package if you have NetBSD, as NetBSD has a libedit library, which provides Readline compatibility.
OpenSSL is an Open Source implementation of the SSL/TLS protocols. OpenSSL is commonly used with utilities such as OpenSSH and Apache-SSL. PostgreSQL can make use of OpenSSL for encrypted connectivity between the psql client application and the PostgreSQL backend. You may also want to consider OpenSSL if you wish to use Stunnel. More information on OpenSSL is located at http://www.openssl.org. Installing and configuring Stunnel for use with PostgreSQL is discussed in Chapter 8.
Tcl/Tk is a combination programming language and graphical toolkit. Although we don't cover the use of Tcl with PostgreSQL, we do cover the use of PgAccess, which is written in Tcl. If you wish to utilize the PgAccess application you will need to install the Tcl/Tk software. The website for Tcl/Tk is http://tcl.activestate.com.
The JDK is the Java Development Kit. It is required for Java development; hence, it is required by PostgreSQL if you wish to enable JDBC support. Ant is a Java-based build tool (somewhat like gmake) that is also required for JDBC support. The JDK can be downloaded from http://java.sun.com/j2se/index.html, and Ant can be downloaded from http://jakarta.apache.org/ant/index.html.
PostgreSQL does not require the extensive use of disk resources. In fact, in comparison to products such as Oracle, PostgreSQL could be considered fat free. However, PostgreSQL is a database, and as with any database, the requirements will grow as you continue to use PostgreSQL.
On an average Linux machine, you will need approximately 50 MB of hard-drive space to unpack the source and another 60 MB of hard drive space to compile the source. If you choose to run the regression tests, you will need an additional 30 MB. Depending on the configuration options you choose, PostgreSQL can take anywhere from 8 to 15 MB of hard drive space once installed.
Note: Remember that PostgreSQL’s space requirements will grow as you use the system! Be sure to plan ahead for the amount of data you will be storing.
Trying to install on a system lacking in disk space is potentially dangerous! Before installing PostgreSQL, we recommend that you check your filesystem to be sure you have enough disk space in your intended installation partition (e.g., /usr/local). If you have a GNU-based system, the df command should be at your disposal. Example 2-4 checks for free disk space, reported in 1k blocks.