Fork of shvaber/da-postgresql (Poralix), maintained at OpenIaaS/da-postgresql.
Public beta — not production-certified.
Version 0.3.5 is under active validation on DirectAdmin with PHP 8.2–8.5. PostgreSQL 15 or newer is required. On PostgreSQL 14 the plugin role
da_pg_pluginhasCREATEROLE, which can mintSUPERUSERroles. Do not run this plugin in production on PostgreSQL 14. Stage first, snapshot, dump before upgrading.
phpPgAdmin is installed from the maintained community fork
ReimuHakurei/phpPgAdmin (v7.14.8-mod), not the abandoned upstream 7.13 tree.
- DirectAdmin with PHP 8.2, 8.3, 8.4 or 8.5 (plugin PHP and the webapps PHP used by phpPgAdmin)
- PHP extensions:
pgsql(andpdo_pgsqlrecommended) - PHP functions:
exec(plugin dumps/restores). Do not rely on the backtick operator — it is deprecated in PHP 8.5 - PostgreSQL 15, 16 or 17 (14 is unsupported for this beta —
CREATEROLEcan mint SUPERUSER). Keeppassword_encryption = scram-sha-256 git,rsync,gzip,unzip- CustomBuild
pgsqlmodule built for each PHP version you run
The plugin does not install PostgreSQL itself. Build PHP --with-pgsql / --with-pdo-pgsql the usual DirectAdmin way.
PHP 8.5 (20 Nov 2025) is supported. Plugin-side changes:
disable_classesis not set inphp.ini(the INI key was removed in 8.5)- no backtick shells, no
(boolean)/(integer)casts, noeach()/get_magic_quotes_gpc() htmlspecialchars()always gets a string (ENT_QUOTES | ENT_SUBSTITUTE)- dynamic properties declared; identifiers go through
pg_escape_identifier pg_close/pg_connectuse the PHP 8PgSql\Connectionobject API
phpPgAdmin 7.14.8-mod already targets PHP 7.4+ and runs on 8.5 (SCRAM, no deprecated constructor args). Rebuild CustomBuild PHP 8.5 with pgsql before switching the plugin PHP.
cd /usr/local/directadmin/plugins
git clone https://github.com/OpenIaaS/da-postgresql.git postgresql
cd postgresql
chmod 700 scripts/*.sh scripts/setup/*.sh exec/*.sh exec/hooks/*.sh
./scripts/install.shinstall.sh now:
- Sets permissions (
data/ticketsis0700 diradmin— not webapps-readable) - Adds the
postgresqlcustom package item - Enables DirectAdmin user backup / restore hooks so PostgreSQL data is included in account backups
- Creates the
diradminPostgreSQL superuser and theda_pg_pluginHTTP role (create_admin.sh --strict, scram auth) — only rotates the superuser password on first install. Warns and continues if PostgreSQL is older than 15 - Installs phpPgAdmin community fork under
/var/www/html/phpPgAdmin - Revokes
PUBLICconnect on customer databases (restrict_access_dbs.sh) - Installs
/etc/cron.d/da-postgresql(daily 03:15 phpPgAdmin update + log rotate) - Activates the plugin
There is no setuid helper. Restore copies uploads in PHP as diradmin.
Re-save every User Package (including admin) and set how many PostgreSQL databases the package may create.
cd /usr/local/directadmin/plugins/postgresql
./scripts/update.sh # asks (TTY) / auto-dumps (GUI)
./scripts/update.sh --backup # always dump first
./scripts/update.sh --skip-backup # skip dumps
./scripts/update.sh --from-github # git pull / rsync from GitHub then installOn a TTY the script asks whether to dump all databases first. Confirm with Y (default, 60s timeout). DirectAdmin’s non-interactive updater dumps automatically unless you pass --skip-backup.
Dumps go to CustomBuild so they survive plugin replacement:
/usr/local/directadmin/custombuild/custom/postgresql-backups/<YYYYMMDD-HHMMSS>/
MANIFEST.txt
globals.sql # tablespaces / roles WITHOUT passwords
<dbname>.dump # pg_dump -Fc
<dbname>.sql.gz # portable SQL
SHA256SUMS
Role passwords (if dumped) go to /root/da-pg-dr/<timestamp>/roles.sql (mode 0600), not CustomBuild.
Last 7 sets are kept. Update does not rotate the diradmin password and keeps the existing phpPgAdmin config.inc.php and SSO files.
Standalone dump (same location):
./scripts/setup/backup_all.sh
./scripts/setup/backup_all.sh --keep=14- Source:
https://github.com/ReimuHakurei/phpPgAdmin(override withPHPPGADMIN_REPO/PHPPGADMIN_REF) - Re-install / update:
/usr/local/directadmin/plugins/postgresql/scripts/setup/phppgadmin.sh - Daily cron pulls that same installer so the webapp tracks the community fork
- Config template:
scripts/setup/phpPgAdmin/config.inc.php-dist(owned_only, extra login + session security, SSO cookies HttpOnly/SameSite) - Do not use phpPgAdmin 7.12/7.13 from the original plugin — they break on PHP 8
| Path | What |
|---|---|
| Plugin update | Prompt / auto dump into CustomBuild custom/postgresql-backups/ |
| DirectAdmin user/reseller/admin backup | Hook user_backup_compress_pre.sh dumps roles + each DB into backup/psql/ inside the archive |
| DirectAdmin restore | Hook user_restore_post.sh → dbimportuser.sh recreates roles/DBs then imports SQL |
| Plugin UI download | gzip SQL dump of one database |
| Plugin UI restore | upload .sql / .sql.gz / .zip / .tar |
Manual per-user:
/usr/local/directadmin/plugins/postgresql/exec/dbbackupuser.sh USER /path/to/dir
/usr/local/directadmin/plugins/postgresql/exec/dbrestore.sh /path/to/dump.sql.gz DBNAMEEnable/disable account-backup hooks:
scripts/setup/custom_backups.sh enable|disable
scripts/setup/custom_restore.sh enable|disable/etc/cron.d/da-postgresql runs scripts/setup/cron_update.sh daily (phpPgAdmin + log rotate — not a full DB dump).
scripts/setup/install_cron.sh enable|disableLogs: /usr/local/directadmin/plugins/postgresql/logs/ (rotated after 14 days).
- PostgreSQL 15+ is required. On 14,
da_pg_plugin CREATEROLEcan mint SUPERUSER. - Tenant HTTP connects as
da_pg_plugin(NOSUPERUSER CREATEDB CREATEROLE NOINHERIT), never asdiradmin. The superuser stays on CLI hooks and the admin page. - Tenant isolation is longest-match against DirectAdmin usernames (
bobdoes not ownbob_shop_*). - SQL identifiers/literals are escaped (
pg_escape_identifier/pg_escape_literal); names must match[A-Za-z_][A-Za-z0-9_]* - New databases:
REVOKE ALL … FROM PUBLIC, roles createdNOSUPERUSER NOCREATEDB NOCREATEROLE - phpPgAdmin SSO: 30s single-use ticket under
data/tickets(0700 diradmin), no password in the ticket. Redeemed by plugin CGIsso_login.raw. phpPgAdminsso_bridge.phpis a 403 stub. The redeem page still auto-POSTs the DB password once to phpPgAdmin (upstream login form). - CSRF HMAC on JSON POSTs; security headers on user and admin CGI
- phpPgAdmin extra login security on; SSO cookies are HttpOnly + SameSite=Lax
- Strict
pg_hba.confusesscram-sha-256(do not forcepassword_encryption = md5) pgpass.conf,plugin-pgpass.conf, SSO files, and/root/da-pg-drdumps are mode0600- Updates never rewrite the
diradminpassword whenpgpass.confalready exists
See SECURITY.md for the threat model and residual risk.
- Removed
get_magic_quotes_gpc()/each()(fatal on PHP 8) - Declared dynamic properties (
query,_DA_CONF,_ERROR_TEXTas array) - Replaced
${var}interpolation - Null-safe
$_SERVER['LANGUAGE']andhtmlspecialchars() pg_connectconninfo quoting;pg_queryon a missing connection no longer TypeErrors- PHP 8.5: dropped
disable_classesfrom pluginphp.ini
- Install PostgreSQL 15+ packages for your OS (
password_encryption = scram-sha-256) - CustomBuild: add
--with-pgsql=/usr(or/usr/pgsql-XX) tocustom/php_extensions/*.confand rebuild PHP (including 8.5) - Install this plugin
- Set package limits
- Confirm Admin → PostgreSQL plugin status page is green
Apache-2.0. Original work © Poralix / Alex Grebenschikov. This fork © OpenIaaS.