RefLib

Reference library for AI

Back

postgresql_16:4.2.4.2 Installation Procedure

PostgreSQL 16 > Server Administration > Installation from Source Code > Building and Installation with Meson > Installation Procedure

The first step of the installation procedure is to configure the build tree for your system and choose the options you would like. To create and configure the build directory, you can start with the meson setup command. meson setup build The setup command takes a builddir and a srcdir argument. If no srcdir is given, Meson will deduce the srcdir based on the current directory and the location of meson.build. The builddir is mandatory.

Running meson setup loads the build configuration file and sets up the build directory. Additionally, you can also pass several build options to Meson. Some commonly used options are mentioned in the subsequent sections. For example: # configure with a different installation prefix meson setup build --prefix=/home/user/pg-install # configure to generate a debug build meson setup build --buildtype=debug # configure to build with OpenSSL support meson setup build -Dssl=openssl

Setting up the build directory is a one-time step. To reconfigure before a new build, you can simply use the meson configure command meson configure -Dcassert=true meson configure's commonly used command-line options are explained in (see postgresql_16:4.2.4.3).

By default, Meson uses the Ninja build tool. To build PostgreSQL from source using Meson, you can simply use the ninja command in the build directory. ninja Ninja will automatically detect the number of CPUs in your computer and parallelize itself accordingly. You can override the number of parallel processes used with the command line argument -j.

It should be noted that after the initial configure step, ninja is the only command you ever need to type to compile. No matter how you alter your source tree (short of moving it to a completely new location), Meson will detect the changes and regenerate itself accordingly. This is especially handy if you have multiple build directories. Often one of them is used for development (the "debug" build) and others only every now and then (such as a "static analysis" build). Any configuration can be built just by cd'ing to the corresponding directory and running Ninja.

If you'd like to build with a backend other than ninja, you can use configure with the --backend option to select the one you want to use and then build using meson compile. To learn more about these backends and other arguments you can provide to ninja, you can refer to the Meson documentation.

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: meson test (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.

To run pg_regress and pg_isolation_regress tests against a running postgres instance, specify --setup running as an argument to meson test.

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.

Once PostgreSQL is built, you can install it by simply running the ninja install command. ninja install

This will install files into the directories that were specified in (see meson-configure). Make sure that you have appropriate permissions to write into that area. You might need to do this step as root. Alternatively, you can create the target directories in advance and arrange for appropriate permissions to be granted. 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.

ninja install should work for most cases, but if you'd like to use more options (such as --quiet to suppress extra output), you could also use meson install instead. You can learn more about meson install and its options in the Meson documentation.

Uninstallation: To undo the installation, you can use the ninja uninstall command.

Cleaning: After the installation, you can free disk space by removing the built files from the source tree with the ninja clean command.

Back