phpPgAdmin is a web-based administration tool for managing PostgreSQL database, and it’s look and feel is very similar to that of phpMyAdmin. If you have work experience on phpMyAdmin, you won’t take much time finding the way to work with phpPgAdmin.
Assuming that you already have installed PostgreSQL on your system. If not, take a look at how to install PostgreSQL 11 / 10 on CentOS 7 / RHEL 7.
Install the dependent packages for phpPgAdmin.
yum install -y php php-cli php-common php-pdo php-pgsql httpd apr apr-util httpd-tools libzip mailcap
The phpPgAdmin available in EPEL repository doesn’t support PostgreSQL 10 and above.
Version of PostgreSQL not supported. Please upgrade to version or later.
So, we will set up phpPgAdmin using the package download from official website.
Download the latest version of phpPgAdmin. Downloading the tarred file would be preferred.
Extract the downloaded archive using tar command.
tar -zxvf REL_5-6-0.tar.gz
Move the extracted files to
mv phppgadmin-REL_5-6-0/ /usr/share/phppgadmin
Copy the configuration file to begin the phpPgAdmin configuration.
mv /usr/share/phppgadmin/conf/config.inc.php-dist /usr/share/phppgadmin/conf/config.inc.php
Set the name for your PostgreSQL instance. This setting will list your instance name in the phpPgAdmin web interface.
$conf['servers']['desc'] = 'PostgreSQL 11';
Add localhost or IP Address of your PostgreSQL instance in the following server parameter.
$conf['servers']['host'] = 'localhost';
If extra login security is true, then logins via phpPgAdmin with no password or certain usernames (pgsql, postgres, root, administrator) will be denied. To enable the postgres login, change it to false.
$conf['extra_login_security'] = false;
To simply hide other’s databases (owned by others) in the list, make the following condition to true.
$conf['owned_only'] = true;
We will need to enable MD5 authentication on PostgreSQL so that we would be able to manage PostgreSQL instances from phpPgAdmin as well as make connections from external machines.
Enabling MD5 authentication increases the security and allows only encrypted password login. Modify the configuration file to accept the MD5 authentication.
### PostgreSQL 11 ### vi /var/lib/pgsql/11/data/pg_hba.conf ### PostgreSQL 10 ### vi /var/lib/pgsql/10/data/pg_hba.conf
Please enter the value as per your requirements in IPv4 connections. Make sure it accepts MD5 passwords.
# TYPE DATABASE USER ADDRESS METHOD # IPv4 local connections: host all all all md5
Restart the PostgreSQL service.
### PostgreSQL 11 ### systemctl restart postgresql-11 ### PostgreSQL 10 ### systemctl restart postgresql-10
Creata a configuration file under
/etc/httpd/conf.d directory so that Apache can serve phpPgAdmin interface.
Copy and paste the below content to the above file.
Alias /phppgadmin /usr/share/phppgadmin <Location /phppgadmin> <IfModule mod_authz_core.c> # Apache 2.4 Require all granted #Require host example.com </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order deny,allow Deny from all Allow from 127.0.0.1 Allow from ::1 # Allow from .example.com </IfModule> </Location>
Restart and enable the HTTPD service.
systemctl restart httpd systemctl enable httpd
If you have SELinux enabled on your system, then you will need to run the below commands; otherwise you will not be able to login to phpPgAdmin.
yum install -y policycoreutils setsebool -P httpd_can_network_connect_db 1
Allow HTTP service in the firewall so that we can access the phpPgAdmin using a browser from external machines.
firewall-cmd --permanent --add-service=http firewall-cmd --reload
Now access the phpPgAdmin from the browser, URL will be:
You will get the below page.
Click on your PostgreSQL instance listed in the left pane (below servers). Login to your PostgreSQL instance with your username and password.
You should now get the database page.