phpPgAdmin is a web-based administration tool for managing PostgreSQL database, and it is very similar to phpMyAdmin, a web-based based tool for managing MySQL (MariaDB).
If you have work experience on phpMyAdmin, then it’s very easy for you to understand the functionalities of phpPgAdmin.
This guide will help you to install phpPgAdmin on Ubuntu 18.04 / Ubuntu 16.04 & LinuxMint 19 / Linux Mint 18.
Prerequisites
Before setting up phpPgAdmin, take a look at how to install PostgreSQL on Ubuntu 18.04 / Ubuntu 16.04 & LinuxMint 19 / Linux Mint 18.
Check the PostgreSQL service is running on the server.
sudo systemctl status postgresql
Output:
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Sat 2019-02-23 11:43:07 IST; 23h ago
Main PID: 6536 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 2323)
CGroup: /system.slice/postgresql.service
Feb 23 11:43:07 server systemd[1]: Starting PostgreSQL RDBMS...
Feb 23 11:43:07 server systemd[1]: Started PostgreSQL RDBMS.
Install phpPgAdmin
phpPgAdmin is available in the base repository, so, you can install it using apt-get install command.
sudo apt-get install -y phppgadmin apache2
Configure PostgreSQL
By default, PostgreSQL accepts the authentication from localhost only. If you want to connect PostgreSQL from external machines, you would need to edit the pg_hba.conf file.
Enter the value as per your requirements in IPv4 and make sure it accepts the md5 password.
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 192.168.1.0/24 md5
Configure phpPgAdmin
Edit /etc/phppgadmin/config.inc.php file.
sudo nano /etc/phppgadmin/config.inc.php
Add your PostgreSQL instances here.
// Display name for the server on the login screen
$conf['servers'][0]['desc'] = 'PostgreSQL 11';
// Hostname or IP address for server. Use '' for UNIX domain socket.
// use 'localhost' for TCP/IP connection on this computer
$conf['servers'][0]['host'] = 'localhost';
// Database port on server (5432 is the PostgreSQL default)
$conf['servers'][0]['port'] = 5432;
phpPgAdmin won’t allow users with no password or certain usernames (pgsql, postgres, root, administrator) to log in.
To override this extra security, change it to false.
$conf['extra_login_security'] = false;
Setting this true simply hide other users databases from the database list. However, they can get the data (from other databases) using SQL queries.
$conf['owned_only'] = false;
Configure Apache
Due to restriction, phpPgAdmin is accessible only on localhost. If you want to access phpPgAdmin web interface from external machines, then you need to edit the apache configuration (phppgadmin.conf) file.