How To Install phpPgAdmin 5.6 on CentOS 7 / RHEL 7

0

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.

This guide will help you to setup phpPgAdmin 5.6 on CentOS 7 / RHEL 7.

Prerequisites

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

Install phpPgAdmin

The phpPgAdmin available in EPEL repository doesn’t support PostgreSQL 10 and above.

Error:

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.

wget https://github.com/phppgadmin/phppgadmin/archive/REL_5-6-0.tar.gz

Extract the downloaded archive using tar command.

tar -zxvf REL_5-6-0.tar.gz

Move the extracted files to /usr/share/phppgadmin directory.

mv phppgadmin-REL_5-6-0/ /usr/share/phppgadmin

Configure 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

Edit /etc/phpPgAdmin/config.inc.php file.

vi /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'][0]['desc'] = 'PostgreSQL 11';

Add localhost or IP Address of your PostgreSQL instance 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’s databases (owned by others) in the list, make the following condition to true.

$conf['owned_only'] = true;

Configure PostgreSQL

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
Use 192.168.1.0/24 instead of all in ADDRESS to enable MD5 authentication for the specific subnet of IP addresses.

Restart the PostgreSQL service.

### PostgreSQL 11 ### 

systemctl restart postgresql-11 

### PostgreSQL 10 ### 

systemctl restart postgresql-10

Configure Apache

Creata a configuration file under /etc/httpd/conf.d directory so that Apache can serve phpPgAdmin interface.

vi /etc/httpd/conf.d/phppgadmin.conf

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

SELinux

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

Firewall

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

Access phpPgAdmin

Now access the phpPgAdmin from the browser, URL will be:

http://your.ip.add.ress/phppgadmin

You will get the below page.

Install phpPgAdmin 5.6 on CentOS 7 - phpPgAdmin Home Page
Install phpPgAdmin 5.6 on CentOS 7 – phpPgAdmin Home Page

Click on your PostgreSQL instance listed in the left pane (below servers). Login to your PostgreSQL instance with your username and password.

Install phpPgAdmin 5.6 on CentOS 7 - phpPgAdmin Login Page
Install phpPgAdmin 5.6 on CentOS 7 – phpPgAdmin Login Page

You should now get the database page.

Install phpPgAdmin 5.6 on CentOS 7 - List of Databases in phpPgAdmin
Install phpPgAdmin 5.6 on CentOS 7 – List of Databases in phpPgAdmin

Conclusion

You have successfully installed phpPgAdmin on CentOS 7 / RHEL 7. Visit the phpPgAdmin’s FAQ page to learn more about phpPgAdmin and Help page if you need support.

You might also like