PostgreSQL and PhpPgAdmin installation on CentOS 7/RHEL 7



PostgreSQl is an Opensource relational Data Base Management System like Oracle, MySQl, MariaDb, SQL Server etc. It is a cross platform application runs under various operating systems like windows, Linux, Unix flavors.

In this article, we will be known about the installation Postgresql and PhpPgAdmin installation in Cent OS 7

By default, postgreSQL available in redhat repository. To install it by using following command

#yum -y install postgresql-server

If we want to install the latest version, we have to install the postgresql repo as follows

#yum install 

Once the repository installation completes, check whether it installed or not by using the following command

#yum repolist

Now install the latest version of the PostgreSQL using the following command

#yum install -y postgresql95-server postgresql95-contrib
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package postgresql95-contrib.x86_64 0:9.5.6-1PGDG.rhel7 will be installed
--> Processing Dependency: postgresql95-libs(x86-64) = 9.5.6-1PGDG.rhel7 for package: postgresql95-contrib-9.5.6-1PGDG.rhel7.x86_64
--> Processing Dependency: postgresql95(x86-64) = 9.5.6-1PGDG.rhel7 for package: postgresql95-contrib-9.5.6-1PGDG.rhel7.x86_64
--> Processing Dependency: for package: postgresql95-contrib-9.5.6-1PGDG.rhel7.x86_64
---> Package postgresql95-server.x86_64 0:9.5.6-1PGDG.rhel7 will be installed
--> Running transaction check
---> Package postgresql95.x86_64 0:9.5.6-1PGDG.rhel7 will be installed
---> Package postgresql95-libs.x86_64 0:9.5.6-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

 Package                                      Arch                           Version                                    Repository                      Size
 postgresql95-contrib                         x86_64                         9.5.6-1PGDG.rhel7                          pgdg95                         530 k
 postgresql95-server                          x86_64                         9.5.6-1PGDG.rhel7                          pgdg95                         4.1 M
Installing for dependencies:
 postgresql95                                 x86_64                         9.5.6-1PGDG.rhel7                          pgdg95                         1.3 M
 postgresql95-libs                            x86_64                         9.5.6-1PGDG.rhel7                          pgdg95                         219 k

Transaction Summary
Install  2 Packages (+2 Dependent packages)

Total download size: 6.1 M
Installed size: 26 M
Downloading packages:
(1/4): postgresql95-contrib-9.5.6-1PGDG.rhel7.x86_64.rpm                                                                              | 530 kB  00:00:03
(2/4): postgresql95-libs-9.5.6-1PGDG.rhel7.x86_64.rpm                                                                                 | 219 kB  00:00:00
(3/4): postgresql95-9.5.6-1PGDG.rhel7.x86_64.rpm                                                                                      | 1.3 MB  00:00:07
(4/4): postgresql95-server-9.5.6-1PGDG.rhel7.x86_64.rpm                                                                               | 4.1 MB  00:00:21
Total                                                                                                                        242 kB/s | 6.1 MB  00:00:25
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : postgresql95-libs-9.5.6-1PGDG.rhel7.x86_64                                                                                                1/4
  Installing : postgresql95-9.5.6-1PGDG.rhel7.x86_64                                                                                                     2/4
  Installing : postgresql95-server-9.5.6-1PGDG.rhel7.x86_64                                                                                              3/4
  Installing : postgresql95-contrib-9.5.6-1PGDG.rhel7.x86_64                                                                                             4/4
  Verifying  : postgresql95-9.5.6-1PGDG.rhel7.x86_64                                                                                                     1/4
  Verifying  : postgresql95-libs-9.5.6-1PGDG.rhel7.x86_64                                                                                                2/4
  Verifying  : postgresql95-server-9.5.6-1PGDG.rhel7.x86_64                                                                                              3/4
  Verifying  : postgresql95-contrib-9.5.6-1PGDG.rhel7.x86_64                                                                                             4/4

  postgresql95-contrib.x86_64 0:9.5.6-1PGDG.rhel7                               postgresql95-server.x86_64 0:9.5.6-1PGDG.rhel7

Dependency Installed:
  postgresql95.x86_64 0:9.5.6-1PGDG.rhel7                                    postgresql95-libs.x86_64 0:9.5.6-1PGDG.rhel7


Now enable and start PostgreSQL as follows

#/usr/pgsql-9.5/bin/postgresql95-setup initdb
#systemctl enable postgresql-9.5
#systemctl start postgresql-9.5

Noweditpg_hba.conf and change identity and peer to trust

#vi /var/lib/pgsql/9.5/data/pg_hba.conf

To enable TCP/IP connections, edit the file postgres.conf, uncomment port & listen address and also change listen address to * to allow connections.

#vi /var/lib/pgsql/9.5/data/postgresql.conf

After the changes complete, restart the postgresql service as follows

#systemctl restart postgresql-9.5

Now install phpPgAdmin as follows

#yum -y install phpPgAdmin httpd

Edit the configuration file /etc/httpd/conf.d/phpPgAdmin.conf and add the hosts from which we access the phpPgAdmin web console.

Now restart httpd service by using systemctl command. Access the phpPgAdmin by using address http://ip-address/phpPgAdmin

Enjoy phpPgAdmin, if you want to join this discussion, feel free to leave a comment!

Read also: phpMyAdmin installation on Linux