postgresql_16:4.2.3.2 Installation Procedure
PostgreSQL 16 > Server Administration > Installation from Source Code > Building and Installation with Autoconf and Make > Installation Procedure
The first step of the installation procedure is to configure the source tree for your system and choose the options you would like. This is done by running the configure script. For a default installation simply enter: ./configure This script will run a number of tests to determine values for various system dependent variables and detect any quirks of your operating system, and finally will create several files in the build tree to record what it found.
You can also run configure in a directory outside the source tree, and then build there, if you want to keep the build directory separate from the original source files. This procedure is called a *VPATH* build. Here's how: mkdir build_dir cd build_dir /path/to/source/tree/configure [options go here] make
The default configuration will build the server and utilities, as well as all client applications and interfaces that require only a C compiler. All files will be installed under /usr/local/pgsql by default.
You can customize the build and installation process by supplying one or more command line options to configure. Typically you would customize the install location, or the set of optional features that are built. configure has a large number of options, which are described in (see postgresql_16:4.2.3.3).
Also, configure responds to certain environment variables, as described in (see postgresql_16:4.2.3.4). These provide additional ways to customize the configuration.
To start the build, type either of: make make all (Remember to use GNU make.) The build will take a few minutes depending on your hardware.
If you want to build everything that can be built, including the documentation (HTML and man pages), and the additional modules (contrib), type instead: make world
If you want to build everything that can be built, including the additional modules (contrib), but without the documentation, type instead: make world-bin
If you want to invoke the build from another makefile rather than manually, you must unset MAKELEVEL or set it to zero, for instance like this: build-postgresql: $(MAKE) -C postgresql MAKELEVEL=0 all Failure to do that can lead to strange error messages, typically about missing header files.
If you want to test the newly built server before you install it, you can run the regression tests at this point. The regression tests are a test suite to verify that PostgreSQL runs on your machine in the way the developers expected it to. Type: make check (This won't work as root; do it as an unprivileged user.) See (see postgresql_16:4.18) for detailed information about interpreting the test results. You can repeat this test at any later time by issuing the same command.
Note
If you are upgrading an existing system be sure to read (see postgresql_16:4.4.6), which has instructions about upgrading a cluster.
To install PostgreSQL enter: make install This will install files into the directories that were specified in (see configure). Make sure that you have appropriate permissions to write into that area. Normally you need to do this step as root. Alternatively, you can create the target directories in advance and arrange for appropriate permissions to be granted.
To install the documentation (HTML and man pages), enter: make install-docs
If you built the world above, type instead: make install-world This also installs the documentation.
If you built the world without the documentation above, type instead: make install-world-bin
You can use make install-strip instead of make install to strip the executable files and libraries as they are installed. This will save some space. If you built with debugging support, stripping will effectively remove the debugging support, so it should only be done if debugging is no longer needed. install-strip tries to do a reasonable job saving space, but it does not have perfect knowledge of how to strip every unneeded byte from an executable file, so if you want to save all the disk space you possibly can, you will have to do manual work.
The standard installation provides all the header files needed for client application development as well as for server-side program development, such as custom functions or data types written in C.
Client-only installation: If you want to install only the client applications and interface libraries, then you can use these commands: make -C src/bin install make -C src/include install make -C src/interfaces install make -C doc install src/bin has a few binaries for server-only use, but they are small.
Uninstallation: To undo the installation use the command make uninstall. However, this will not remove any created directories.
Cleaning: After the installation you can free disk space by removing the built files from the source tree with the command make clean. This will preserve the files 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 within the same source tree you must do this and re-configure for each platform. (Alternatively, use a separate build tree for each platform, so that the source tree remains unmodified.)
If you perform a build and then discover that your configure options were wrong, or if you change anything that configure investigates (for example, software upgrades), then it's a good idea to do make distclean before reconfiguring and rebuilding. Without this, your changes in configuration choices might not propagate everywhere they need to.