Last Updated:

How to Configure PostgreSQL

Before compiling, you need to customize the source code and set the configuration according to your needs. For this purpose, the configure script is used.

The configure script also checks the relationships required to compile PostgreSQL. As part of the link checking process, the script automatically creates the files that are required for gmake to work.

The standard installation script is run with the ./configure command. To enable features that are disabled by default, include the appropriate key in the ./configure command. A complete list of all configuration keys is displayed by the ./configure --help command.

Most likely, the default configuration will be different from the one you need. For a normal PostgreSQL installation, it is recommended to specify at least the following keys:

  • --with-CXX – building the libpq++ library allows you to create C++ programs that work with PostgreSQL;
  • --enable-odbc – support for connecting to PostgreSQL from programs that have a compatible ODBC driver (for example, Microsoft Access);
  • --enable-multibyte – the ability to use multibyte encodings (for example, for Japanese);
  • --with-maxbackends=number – the parameter specifies the maximum number of connections (the default is 32).

The following is a complete list of configuration options.

  • --реfiх=prefix. The directory that hosts the installed files instead of the default /usr/local/pgsql directory.
  • --exec-prefix=prefix. The directory where the system executable files are located.
  • --bindir=directory. A directory for hosting custom executable files (for example, psql).
  • --datadir=directory. Directory for installing data files used by PostgreSQL programs and for sample configuration files. The directory specified by this parameter is not used as an alternate directory for storing data; it merely contains read-only PostgreSQL service files.
  • --sysconfigdir=directory. The directory for placing the system configuration files. By default, files are stored in the etc subdirectory of the installation base directory.
  • --libdigg=directory. The directory for placing library files. On a Linux system, this directory must also be specified in the ld.so.conf file.
  • --includedigg=directory. The directory for placing the C and C++ header files. By default, header files are stored in the include subdirectory of the base installation directory.
  • --docdir=directory. The directory where the documentation files are located. PostgreSQL man pages are stored in a different directory.
  • --mandig=directory. Directory for placing man-pages.
  • --with-includes=directory. Lists the directories that are viewed when searching for additional header files. List items are separated by colons (:).
  • --with-libraries=directories. Lists the directories that are viewed when searching for additional library files. List items are separated by colons (:).
  • --enable-locale. Support for local contexts. Negatively affects performance and is included only if you work in a non-English-speaking environment.
  • --enable-multibyte. Support for multibyte encodings. Specifying this key enables support for non-ASCII characters; especially often used when working with Japanese, Chinese and Korean.
  • --with-pgport=number. The default port number used by PostgreSQL. Can be changed when you run the postmaster application.
  • --with-maxbackends=number. The maximum number of connections (the default is 32).
  • --with-CXX. The installation process automatically compiles the C++ front-end library. The key is specified if you intend to develop C++ applications that work with PostgreSQL.
  • --with-perl. During the installation process, the Perl interface module is automatically compiled. This module must be installed in a directory normally owned by the root user, so you will need to have root privileges to complete the installation if you select this mode. The key is required only if you intend to use the pi/Perl procedural language.
  • --with-python. During the installation process, the PostgreSQL Python interface module is automatically compiled. As with the --with-perl switch, you must have root privileges to complete the installation with this key. The key is required only if you intend to use the procedural language pi/Python.
  • --with-tcl. Enabling Tel. This key installs PostgreSQL applications and extensions that require Tel, such as pgaccess (a popular graphical database client) and the pl/Tcl procedural language.
  • --without-tk. Tel support is compiled without support for the Tk graphical toolkit. If the key is specified in conjunction with the --with-tcl switch, PostgreSQL applications that require Tk support (for example, pgtksh and pgaccess) are not installed.
  • --with-tclconfig=directory--with-tkconfig=directory. The directory for placing the Tel or Tk configuration file (tclconfig.sh or tkConfig.sh depending on the key). These two files are installed when installing Tcl/Tk, and the data stored in them is used by the Tcl/Tk interface modules in PostgreSQL.
  • --enable-odbc. Enable ODBC support.
  • --with-odbcinst=directory. The directory where the ODBC driver looks for the odbcinst.ini file. By default, the file is located in the etc subdirectory of the base installation directory.
  • --with-krb4=directory--with-krb5=directory. Support for the Kerberos authentication system. Kerberos is not discussed in this book.
  • --with-krb-srvnam=name. The name of the Kerberos service. The default name is postgres.
  • --with-openssl=directory. Support for encrypted data exchange with the database via SSL protocol. The OpenSSL package must be installed in the specified directory and configured correctly. The key is required if you are going to use stunnel.
  • --with-Java. Support for Java/JDBC. To properly compile PostgreSQL with this key, you need the Ant and JDK packages.
  • --enable-syslog. Syslog using the syslog daemon.
  • --enable-debug. All PostgreSQL libraries and applications are compiled with the inclusion of debug symbolic names. This results in slow performance and an increase in the number of binaries, but symbolic names make it easier to diagnose errors that occur when working with PostgreSQL.
  • --enable-cassert. Enable assertions mode. mode slows down postgresql and is used only in the process of debugging the postgresql system itself

If, after compiling PostgreSQL, it turns out that you forgot to enable the desired mode, return to this step, change the configuration and continue the process of building and installing PostgreSQL. If the check-in occurs before the installation is complete, be sure to run the gmake clean command in the top-level directory of the source hierarchy (usually /usr/local/src/postgresql-["epc"^]). As a result, all intermediate object and partially compiled files will be deleted.