Published on Aug 28 2020 in Control Panels Databases Non-Java

CentOS users please see this tutorial. To use Directadmin PostgreSQL plugin you will first need to ensure PostgreSQL server is installed as well as PostgreSQL support in PHP exists. See how you can install PostgreSQL 12 and build related PHP module in Ubuntu 18.04.

To install PostgreSQL run as root:

apt update
apt -y upgrade
wget --quiet -O - | apt-key add -
echo "deb `lsb_release -cs`-pgdg main" | tee  /etc/apt/sources.list.d/pgdg.list
apt -y update
apt -y install postgresql-12 postgresql-client-12
ln -s /var/lib/postgresql /var/lib/pgsql

A few checks:

systemctl is-enabled postgresql
su - postgres -c 'psql -c "SELECT version()"'
su - postgres -c 'psql -tA -c "SHOW data_directory;"'

Ensure listen_addresses = '*' is in /etc/postgresql/12/main/postgresql.conf and run systemctl restart postgresql if postgresql.conf has been modified.

grep -qP '^listen_addresses\s*=\s*'\''\*'\''' /etc/postgresql/12/main/postgresql.conf || \
sed -i -r "s|^\s*#?\s*(listen_addresses\s*=\s*).*|\1'*'|" /etc/postgresql/12/main/postgresql.conf

Enabling PostgreSQL support in default PHP

If you skip this, you will get blank page and respective error message in /var/lib/pgsql/plugin-php.log. First test for existence of libpq-fe.h:

[ -f `pg_config --includedir`/libpq-fe.h ] && echo "devel installed" || apt -y install libpq-dev

Then update configure.php73 (as we use 7.3 in this example) or whatever your main PHP version is:

cd /usr/local/directadmin/custombuild
./build used_configs | grep 'PHP (default) configuration' | awk '{print $NF}'

mkdir -p /usr/local/directadmin/custombuild/custom/php
\cp -fp /usr/local/directadmin/custombuild/configure/php/configure.php73 /usr/local/directadmin/custombuild/custom/php

Add your --with-pgsql= and --with-pdo-pgsql= parameters to custom/php/configure.php73 and build php. In this case ‘include’ directory is in /usr/pgsql-12 so we use this value:

pg_config --includedir
perl -0777 -i.bak -pe 's|^(\./configure \\)$(?!\s*--with-pgsql)|$1\n\t--with-pgsql=/usr/include/postgresql --with-pdo-pgsql=/usr/include/postgresql \\|ms' /usr/local/directadmin/custombuild/custom/php/configure.php73
./build php d

Similarly you can add PostgreSQL support to other php versions.

Installation of the plugin is the same as shown in screencast for Centos 7. A reply from the installer is shown below.

DirectAdmin PostgreSQL plugin