Debian – Logic behind Postgres binary installation path on Debian

debianfhspostgresql

It appears that the Postgresql installation is split into three folder locations on Debian:

Configuration: /etc/postgresql

Binaries: /usr/lib/postgresql

Data: /var/lib/postgresql

I understand the benefits of splitting up the configuration files and the data, however, the binaries location is confusing to me — why wouldn't it simply be in /usr/bin?

More to the point, why would some binaries go into /usr/bin and others into /usr/lib?

Best Answer

This splitting is pretty typical for most services. I'm on Fedora but most distributions do the same in terms of organizing files based on their type, into designated areas.

Taking a look at the Postgres SQL server:

  1. The configuration files go into /etc/
  2. Executables go into /usr/bin
  3. Libraries go into /usr/lib64/pgsql/
  4. Locale information goes into /usr/share/locale/
  5. Man pages and docs goes into /usr/share/
  6. Data goes into /var/lib/

The rational for having a libraries directory usr/lib/postgresql in your case, which is equivalent to /usr/lib64/pgsql/ for my install, is that applications can make use of libraries of functions that are provided by Postgres. These functions are contained in these libraries.

So as an application developer, you could link against the libraries here to incorporate function calls into Postgres, into your application. These libraries will often times include API documentation, and the developers of Postgres make sure to keep their API specified and working correctly through these libraries, so that applications that make use of them, can be guaranteed that they'll work correctly with this particular version of Postgres.

Related Question