Installation Procedure

Caution

Before installing the Red Hat Database from source, be certain to uninstall the RPM packages for Red Hat Database. See your Red Hat Linux documentation for information on how to use GnoRPM to uninstall packages.

Step 1: Obtain the Source

You can find the PostgreSQL software in /usr/src/redhat/SOURCES/postgresql-7.1.2.tar.gz after you install the source package.

Log in as root and copy the tarball to a temporary directory. Change to that directory and uncompress the package. Enter:
tar -xzvf postgresql-7.1.2.tar.gz
Then enter:
cd postgresql-7.1.2
to move to the top of the source tree.

Step 2: Configure the Source Tree

The next step of the installation procedure is to configure the source tree for your system. You do this by running the configure script, either with or without command-line options. For a default installation, enter:
./configure
PostgreSQL is configured by default with the options: ./configure --with-CXX --prefix=/usr/local/pgsql

The script runs a number of tests to guess values for various system-dependent variables and to detect the characteristics of your operating system. When the tests are completed, the script creates several files in the build tree to record the variables it found and the values it used.

The default configuration builds the server, the utilities, and all client applications and interfaces that require only a C compiler. All files are installed under /usr/local/pgsql by default. However, you can customize the build and installation process by supplying one or more of the following command-line options to the configure script. If you choose to change where files are installed, ensure that you have the appropriate permissions to write into those areas.

Specifying a different installation directory

To install all files under the directory PREFIX instead of /usr/local/pgsql, use the option --prefix=PREFIX. The actual files are installed into various subdirectories; no files are installed directly into the PREFIX directory.

If you have special needs, you can also customize the individual subdirectories with the following options.

Specifying the installation directory for architecture-dependent files

To install architecture-dependent files under a different directory (EXEC-PREFIX) rather than PREFIX, use the option --exec-prefix=EXEC-PREFIX. This can be useful to share architecture-independent files between hosts. If you omit this, then EXEC-PREFIX is set to PREFIX and both architecture-dependent and architecture-independent files are installed under the same tree, which is probably what you want.

Specifying the installation directory for executable programs

To install the executable programs under a different directory, use the option --bindir=DIRECTORY. The default is EXEC-PREFIX/bin, which normally resolves to /usr/local/pgsql/bin.

Specifying the installation directory for read-only data files

To install the read-only data files used by the installed programs under a different directory, use the option --datadir=DIRECTORY. The default is PREFIX/share. Note that this has nothing to do with where your database files will be placed.

Specifying the installation directory for configuration files

To install the various configuration files under a different directory, use the option --sysconfdir=DIRECTORY. The default is PREFIX/etc.

Specifying the installation directory for libraries and dynamically loadable modules

To install libraries and dynamically loadable modules under a different directory, use the option --libdir=DIRECTORY. The default is EXEC-PREFIX/lib.

Specifying the installation directory for C and C++ header files

To install C and C++ header files under a different directory, use the option --includedir=DIRECTORY. The default is PREFIX/include.

Specifying the installation directory for the documentation files

To install documentation files, except for "man" pages, under a different directory, use the option --docdir=DIRECTORY. The default is PREFIX/doc.

Specifying the installation directory for the man pages

To install the man pages that come with PostgreSQL under a different directory, use the option --mandir=DIRECTORY. By default, man pages are installed in their respective manx subdirectories under PREFIX/man.

Note

To reduce the pollution of shared installation locations (such as /usr/local/include), the string "/postgresql" is automatically appended to datadir, sysconfdir, includedir, and docdir, unless the fully expanded directory name already contains the string "postgres" or "pgsql". For example, if you choose /usr/local as prefix, the C header files will be installed in /usr/local/include/postgresql. If the prefix is /opt/postgres, then the files will be installed in /opt/postgres/include.

Specifying a list of directories for compiler header files

To add a list of directories to the list the compiler searches for header files, use --with-includes=DIRECTORIES where DIRECTORIES is a colon-separated list of directories. If you have optional packages (such as GNU Readline) installed in a non-standard location, you have to use this option and probably the corresponding --with-libraries option.

Example: --with-includes=/opt/gnu/include:/usr/sup/include.

Specifying a list of directories for compiler libraries

To add a list of directories to the list the compiler searches for libraries, use --with-libraries=DIRECTORIES where DIRECTORIES is a colon-separated list of directories. You will probably have to use this option (and the corresponding --with-includes option) if you have packages installed in non-standard locations.

Example: --with-libraries=/opt/gnu/lib:/usr/sup/lib.

Enabling locale support

To enable locale support, use --enable-locale. There is a performance penalty associated with locale support, but if you are not in an English-speaking environment, you will most likely need this.

Enabling recode support

To enable single-byte character set recode support, use --enable-recode. See the Administrator and User's Guide for details.

Enabling multibyte-character encodings

To enable the use of multibyte-character encodings, use --enable-multibyte. This is primarily for languages such as Japanese, Korean, and Chinese. See the Administrator and User's Guide for details.

Setting the default port number for server and clients

To set NUMBER as the default port number for server and clients, use --with-pgport=NUMBER. The default is 5432. The port can always be changed later on, but if you specify it here then both server and clients will have the same default compiled in, which can be very convenient.

Building the C++ interface library

To build the C++ interface library, use --with-CXX.

Building the Perl 5 (or higher) interface module

To build the Perl interface module, use --with-perl. The Perl interface will be installed at the usual place for Perl modules (typically under /usr/lib/perl), so you must have root access to perform the installation step (see Red Hat Database). You need to have Perl 5 installed to use this option.

Building the Python interface module

To build the Python interface module, use --with-python. You need to have root access to be able to install the Python module at its default place (/usr/lib/pythonx.y). To be able to use this option, you must have Python installed and your system needs to support shared libraries. If you instead want to build a new complete interpreter binary, you will have to do it manually.

Building components that require Tcl/Tk

To build components that require Tcl/Tk, which are libpgtcl, pgtclsh, pgtksh, pgaccess, and PL/Tcl, use --with-tcl, but see below about the option --without-tk.

Excluding components that require Tk

If you specify --with-tcl and --without-tk, programs that require Tk (that is, pgtksh and pgaccess) will be excluded.

Specifying the location of tclConfig.sh and tkConfig.sh

The files tclConfig.sh and tkConfig.sh contain certain configuration information that is needed to build modules interfacing to Tcl or Tk. These files are normally found automatically at their well-known location, but if you want to use a different version of Tcl or Tk, you can specify the directory where to find them. Use --with-tclconfig=DIRECTORY and --with-tkconfig=DIRECTORY.

Building the ODBC driver package.

To build the ODBC driver package, use --enable-odbc.

Specifying where the ODBC driver searches for odbcinst.ini

To specify the directory where the ODBC driver searches for its odbcinst.ini configuration file, use --with-odbcinst=DIRECTORY. The default is /usr/local/pgsql/etc (or whatever you specified as --sysconfdir). A default file will be installed there. If you intend to share the odbcinst.ini file between several ODBC drivers, you may want to use this option.

Building with support for Kerberos authentication.

To build with support for Kerberos authentication, use --with-krb4=DIRECTORY or --with-krb5=DIRECTORY. You can use either Kerberos version 4 or 5, but not both. The DIRECTORY argument specifies the root directory of the Kerberos installation; /usr/athena is the default. If the relevant headers files and libraries are not under a common parent directory, then you must use the --with-includes and --with-libraries options in addition to this option. If, on the other hand, the required files are in a location that is searched by default (for example, /usr/lib), you can omit the argument.

configure will check for the required header files and libraries to make sure that your Kerberos installation is sufficient before proceeding.

Setting the name of the Kerberos service principal.

To set the name of the Kerberos service principal, use --with-krb-srvnam=NAME. The default is "postgres". There is probably no reason to change this.

Building with support for SSL connections.

To build with support for SSL (encrypted) connections, use --with-openssl=DIRECTORY. This requires that the OpenSSL package be installed. The DIRECTORY argument specifies the root directory of the OpenSSL installation; the default is /usr/local/ssl.

configure will check for the required header files and libraries to make sure that your OpenSSL installation is sufficient before proceeding.

Building the JDBC driver and associated packages.

To build the JDBC driver and associated Java packages, use --with-java. This option requires Ant to be installed (as well as a JDK, of course).

Enabling the PostgreSQL server to use the syslog logging facility.

To enables the PostgreSQL server to use the syslog logging facility, use --enable-syslog. (Using this option does not mean that you must log with syslog or even that it will be done by default, it simply makes it possible to turn this option on at run time.)

Compiling all programs and libraries with debugging symbols.

To compile all programs and libraries with debugging symbols, use --enable-debug. This means that you can run the programs through a debugger to analyze problems. This enlarges the size of the installed executables considerably, and on non-gcc compilers it usually also disables compiler optimization, causing slowdowns. However, having the symbols available is extremely helpful for dealing with any problems that may arise. Currently, this option is considered of marginal value for production installations, but you should have it on if you are doing development work. You should not use this option on production systems.

Enabling assertion checks in the server.

To enable assertion checks in the server, which test for many "cannot happen" conditions, use --enable-cassert. This is invaluable for code development purposes, but the tests slow performance a little. Also, having the tests turned on may decrease the stability of your server! The assertion checks are not categorized for severity, and so what might be a relatively harmless bug will still lead to postmaster restarts if it triggers an assertion failure. Currently, this option is not recommended for production use, but you should have it on for development work.

If you prefer a C or C++ compiler different from the one configure picks, you can set the environment variables CC and CXX, respectively, to the program of your choice. Similarly, you can override the default compiler flags with the CFLAGS and CXXFLAGS variables. For example:
env CC=/opt/bin/gcc CFLAGS='-02 -pipe' ./configure

Step 3: Start the Build

To start the build, enter:
make
The build can take anywhere from 5 minutes to half an hour. The last line displayed should be
All of PostgreSQL is successfully made. Ready to install.

To enable specifying absolute paths directly to the CREATE DATABASE commands without defining environment variables, you must compile PostgreSQL with the C preprocessor macro ALLOW_ABSOLUTE_DBPATHS defined. One way to do this is:
make CPPFLAGS=-DALLOW_ABSOLUTE_DBPATHS all

Step 4: Perform Regression Tests

If you want to test the newly built server before you install it, you can run the regression tests at this point. The regression test suite verifies that PostgreSQL runs on your machine in the way the developers expected it to. Enter:
cd src/test/regress
make check
It is possible that some tests will fail, due to differences in error message wording or floating point results. You can repeat this test at any later time by issuing the same command.

Step 5: Install the Files

Note

If you are upgrading an existing system and are going to install the new files over the old ones, you should have backed up your data and shut down the old server by now, as explained in the section called Step 6 – Are You Already Using PostgreSQL? in Chapter 1 above.

To install the Red Hat Database, as root, enter:
make install
This installs files into the directories that were specified in the section called Step 2: Configure the Source Tree. Make sure that you have appropriate permissions to write into that area. Normally you need to log on as root to perform this step. However, you could create the target directories in advance and arrange for appropriate permissions to be granted.

If you built the Perl or Python interfaces and you were not the root user when you executed the above command, then that part of the installation probably failed. In that case, become the root user and enter:
make -C src/interfaces/perl5 install
make -C src/interfaces/python install
Due to a quirk in the Perl build environment, the first command will actually rebuild the complete interface and then install it. This is not harmful, just unusual. If you do not have superuser access, you are on your own: you can still take the required files and place them in other directories where Perl or Python can find them, but how to do that is beyond the scope of this manual.

The standard install installs only the header files needed for client application development. If you plan to do any server-side program development (such as custom functions or datatypes written in C), then you may want to install the entire Red Hat Database include tree into your target include directory. To do that, enter
make install-all-headers
This adds a megabyte or two to the install footprint, and is only useful if you do not intend to keep the whole source tree for reference. (If you do, you can just use the source's include directory when building server-side software.)

Client-only installation. If you want to install only the client applications and interface libraries, use these commands:
make -C src/bin install
make -C src/interfaces install
make -C doc install

To undo the installation, use the command make uninstall. However, this will not remove the Perl and Python interfaces and it will not remove any directories.

Post-Installation

After the installation you can make room by removing the built files from the source tree with the make clean command. This will preserve the choices made by the configure program, so that you can rebuild everything with make later on. To reset the source tree to the state in which it was distributed, use make distclean. If you are going to build for several platforms from the same source tree, you must do this and re-configure for each build.