Sep 072015
 

phpPgAdminphpPgAdmin is a web based administration tool for managing PostgreSQL database, it is very similar in look of phpMyAdmin. If you have a work experience on phpMyAdmin, you wont take much time in finding the way to work with. This guide will help you to setup phpPgAdmin on CentOS 7 / RHEL 7.

Installing phpPgAdmin:

Before installing, take a look at how to install PostgreSQL on CentOS 7. If you have followed PostgrqSQL install, you do not need to steup EPEL.

Here is the link to setup EPEL repository on CentOS 7.

yum -y install phpPgAdmin php-pgsql httpd php

Configuring phpPgAdmin:

Edit  /etc/phpPgAdmin/config.inc.php file, we have to modify the admin file to enable the browser access.

vi /etc/phpPgAdmin/config.inc.php

Add the localhost in the following server parameter.

$conf['servers'][0]['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 databases in the list make following condition to true – this does not in any way prevent your users from seeing other database by other means.

$conf['owned_only'] = true;

Configuring PostgreSQL:

Modify config file to accept the authentication from the remote networks.

vi /var/lib/pgsql/9.3/data/pg_hba.conf

Please enter the value as per your requirements inIPv4 and Ipv6 connections and make sure it accepts md5 passwords.

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             192.168.2.0/24         md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

Configuring Apche:

By-default phpPgAdmin places the web config file in /etc/httpd/conf.d directory; it has the rules and access permission for the web access. In CentOS 7, web access is managed by mod_authz_core.cmodule; so normal allow or deny rules wont work even if you modify.

vi /etc/httpd/conf.d/phpPgAdmin.conf

Default config will look like below.

Alias /phpPgAdmin /usr/share/phpPgAdmin

<Location /phpPgAdmin>
<IfModule mod_authz_core.c>
# Apache 2.4
Require local
#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>

Please comment Require local and add Require all granted just below to commented line, it will look like below.

Alias /phpPgAdmin /usr/share/phpPgAdmin

<Location /phpPgAdmin>
<IfModule mod_authz_core.c>
# Apache 2.4
# Require local
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 the services.

systemctl restart postgresql-9.3.service
 
systemctl restart httpd.service

Accessing phpPgAdmin:

Now access the phpPgAdmin from the browser, url will be http://your-ip-address/phpPgAdmin.

CentOS 7 - phpPgAdmin Home page
CentOS 7 – phpPgAdmin Home page

Login by using postgres user.

CentOS 7 - phpPgAdmin Login page
CentOS 7 – phpPgAdmin Login page

You will get the database page.

CentOS 7 - phpPgAdmin Databases
CentOS 7 – phpPgAdmin Databases

That’s All. Hope this helped you, we welcome your comments.