Here is the step by step instructions on how to install phpPgAdmin on Centos 7. PostgreSQL is a great database and phpPgAdmin is a web-based administration tool for PostgreSQL. Probably most postgresql DBA's will use the command line or pgadmin3 but if you are like me, using postgresql in a vps webserver somewhere then phpPgAdmin is a great timesaver tool.
You need to have epel repository available on your server.
yum -y install epel-release
In this section we are going to assume you are using the default http server and php packages that comes with CentOS 7. the command below will install phpPgAdmin including php and the webserver. If the default httpd and php are already installed then the command will simply skip them.
yum -y install php-pgsql httpd php
Download and Uncompress phpPgAdmin
tar -jxvf phpPgAdmin-5.6.0.tar.bz2 ; mv phpPgAdmin-5.6.0 phpPgAdmin
Edit /etc/phpPgAdmin/config.inc.php file, we have to modify the admin file to enable the browser access.
Add the localhost 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 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;
If selinux is enabled then you need to set selinux to allow httpd to connect to your database via network sockets.
setsebool -P httpd_can_network_connect_db on setsebool -P httpd_can_network_connect on
phpPgAdmin connects to the local postgresql server via network. We have to configure our postgresql server to accept local connections via md5 authentication.
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
Create the following config file in /etc/httpd/conf.d/phpPgAdmin.conf
Alias /phpPgAdmin /var/www/html/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-11.service systemctl restart httpd.service
You can now browse to your server IP via a browser and you should get the following page:
The login page.
After successfull login.