The installation of PostgreSQL from source 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 Section 2.2.3."
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 <bug-make@gnu.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 version of GCC is the 3.x series. 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.
Example 2-2. Verifying GCC
$ gcc --version Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux Thread model: posix gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) [root@jd2 ~]# gcc --version gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) Copyright (C) 2004 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.
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.
![]() | 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 Section 3.2.
Tcl is a programming language and graphical toolkit. We do not review the use of Tcl with PostgreSQL.
PostgreSQL has the ability to use Perl as a procedural language, plPerl. To correctly use plPerl you will need perl installed as a shared library. We will discuss creating procedures with plPerl later in the book.
PostgreSQL has the ability to use Python as a procedural language, plPython. To correctly use plPython you will need perl installed as a shared library. We will discuss creating procedures with plPython later in the book.
PostgreSQL has the ability to use PHP as a procedural language, plPHP. To correctly use plPHP you will need PHP installed as a shared library. We will discuss creating procedures with plPHP later in the book. At the time of this writing plPHP was not included as part of the PostgreSQL source. You can however download it from http://www.commandprompt.com/plphp . It is open source under the PostgreSQL and PHP licenses.
PostgreSQL has the ability to use Java as a procedural language, pljava. To correctly use plJava you will need the a Java JVM. At the time of this writing plJava was not included as part of the PostgreSQL source. You can however download if from http://gborg.postgresql.org/project/pljava/projdisplay.php.We will discuss creating procedures with plJava later in the book.
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 65 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 21 to 23 MB of hard drive space once installed.
![]() | 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.