• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to Install PostgreSQL 9.4 And phpPgAdmin in CentOS

238

Installing PostgreSQL 9.4 And phpPgAdmin In CentOS 7

PostgreSQL is a dynamic, free object-relational database system which supports all the major operating systems. Installation of PostgreSQL 9.4 and phpPgAdmin in CentOS is explained in this article.


To Install PostgreSQL

Add the PostgreSQL repository by running the following command.

[root@linuxhelp1 ~]# rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm
Retrieving http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm
warning: /var/tmp/rpm-tmp.KkYHl6: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:pgdg-centos94-9.4-1              ################################# [100%]

Utilise the following command to update the repository

[root@linuxhelp1 ~]# yum update
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirror.nbrc.ac.in
 * updates: mirror.nbrc.ac.in
Resolving Dependencies
-->  Running transaction check
--->  Package httpd.x86_64 0:2.4.6-40.el7.centos.1 will be updated
--->  Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be an update
.
.
.
Updated:
  httpd.x86_64 0:2.4.6-40.el7.centos.4         httpd-tools.x86_64 0:2.4.6-40.el7.centos.4         pgdg-centos94.noarch 0:9.4-2        

Complete!

Install postgresql with the following command

[root@linuxhelp1 ~]# yum install postgresql94-server postgresql-contrib -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirror.nbrc.ac.in
 * updates: mirror.nbrc.ac.in
Resolving Dependencies
-->  Running transaction check
--->  Package postgresql-contrib.x86_64 0:9.2.15-1.el7_2 will be installed
-->  Processing Dependency: postgresql-libs(x86-64) = 9.2.15-1.el7_2 for package: postgresql-contrib-9.2.15-1.el7_2.x86_64
-->  Processing Dependency: postgresql(x86-64) = 9.2.15-1.el7_2 for package: postgresql-contrib-9.2.15-1.el7_2.x86_64
-->  Processing Dependency: libpq.so.5()(64bit) for package: postgresql-contrib-9.2.15-1.el7_2.x86_64
.
.
.
Installed:
  postgresql-contrib.x86_64 0:9.2.15-1.el7_2                       postgresql94-server.x86_64 0:9.4.8-1PGDG.rhel7                      

Dependency Installed:
  postgresql.x86_64 0:9.2.15-1.el7_2              postgresql-libs.x86_64 0:9.2.15-1.el7_2    postgresql94.x86_64 0:9.4.8-1PGDG.rhel7   
  postgresql94-libs.x86_64 0:9.4.8-1PGDG.rhel7    uuid.x86_64 0:1.6.2-26.el7                

Complete!

Create the postgresql database by running the following command.

[root@linuxhelp1 ~]# /usr/pgsql-9.4/bin/postgresql94-setup initdb
Initializing database ... OK

Start postgresql service to start automatically on every reboot.

[root@linuxhelp1 ~]# systemctl enable postgresql-9.4.service
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-9.4.service to /usr/lib/systemd/system/postgresql-9.4.service.
[root@linuxhelp1 ~]# systemctl start postgresql-9.4.service

Allow some ports in IP tables as follows to access postgresql from remote systems.

[root@linuxhelp1 ~]# firewall-cmd --permanent --add-port=5432/tcp
success
[root@linuxhelp1 ~]# firewall-cmd --permanent --add-port=80/tcp
success
[root@linuxhelp1 ~]# firewall-cmd --reload
Success

Adjust SELinux by execute the following command to make PostgreSQL work.

[root@linuxhelp1 ~]# setsebool -P httpd_can_network_connect_db 1

Login of PostegreSQL fails, if you didn’ t run the above command.

Use the following command to Switch the postgres user in order to perform postgresql related operations.

[root@linuxhelp1 ~]# su &ndash  postgres

To login to postgresql, enter the command:

-bash-4.2$ psql
psql (9.2.15, server 9.4.8)
WARNING: psql version 9.2, server version 9.4.
Some psql features might not work.
Type " help"  for help.

Set “ postgres”  user password
postgres=# password postgres
Enter new password:
Enter it again:
Create New User and Database
For example, let us create a new user called “ linux”  with password “ linuxc” , and database called “ database1” .
Now create user linux
postgres=# create user linux 
CREATE ROLE
Create database:
postgres=# create database database1 
CREATE DATABASE
set password and Grant access to the database database1 for linux:
postgres=# alter user linux with encrypted password ' linuxc'  
ALTER ROLE
postgres=# grant all privileges on database database1 to linux 
GRANT

Delete Users and Databases
To delete the database, switch to postgres user:
su - postgres
Enter command:
$ dropdb
To delete a user, enter the following command:
$ dropuser

To Configure PostgreSQL-MD5 Authentication

Open pg_hba.conf file and edit as follows.

[root@linuxhelp1 ~]# vim /var/lib/pgsql/9.4/data/pg_hba.conf
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all 192.168.5.0/24 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
host all all ::1/128 md5

Unfold the postgresql.conf file and edit the following lines to connect users from another computers.

[root@linuxhelp1 ~]# vim /var/lib/pgsql/9.4/data/postgresql.conf
listen_addresses = ' localhost' 
port = 5432
max_connections = 100

Restart the services of postgresql to apply changes

[root@linuxhelp1 ~]# systemctl restart postgresql-9.4


To Manage PostgreSQL with phpPgAdmin

phpPgAdmin is a web-based administration utility that is programmed in PHP language. Add EPEL repository, before installing phpPgAdmin.

[root@linuxhelp1 ~]# yum install epel-release -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.nbrc.ac.in
* extras: mirror.nbrc.ac.in
* updates: mirror.nbrc.ac.in
Resolving Dependencies
-->  Running transaction check
--->  Package epel-release.noarch 0:7-6 will be installed
-->  Finished Dependency Resolution
.
.
.
Installed:
epel-release.noarch 0:7-6

Complete!

Run the following command to install phpPgAdmin.

[root@linuxhelp1 ~]# yum install phpPgAdmin -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.nbrc.ac.in
* epel: mirror.rise.ph
* extras: mirror.nbrc.ac.in
* updates: mirror.nbrc.ac.in
Resolving Dependencies
-->  Running transaction check
--->  Package phpPgAdmin.noarch 0:5.1-2.rhel7 will be installed
-->  Processing Dependency: php-pgsql > = 4.2 for package: phpPgAdmin-5.1-2.rhel7.noarch
-->  Running transaction check
--->  Package php-pgsql.x86_64 0:5.4.16-36.1.el7_2.1 will be installed
.
.
.
Installed:
phpPgAdmin.noarch 0:5.1-2.rhel7

Dependency Installed:
php-pgsql.x86_64 0:5.4.16-36.1.el7_2.1

Complete!

Open the phpPgAdmin.conf file and edit it as follows.

[root@linuxhelp1 ~]# vim /etc/httpd/conf.d/phpPgAdmin.conf
Alias /phpPgAdmin /usr/share/phpPgAdmin

# Apache 2.4
Require all granted
#Require host example.com

# Apache 2.2
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from all
# Allow from .example.com

Start and enable the Apache services.

[root@linuxhelp1 ~]# systemctl enable httpd
[root@linuxhelp1 ~]# systemctl start httpd

To Configure phpPgAdmin

Open the config.inc.php and make the following changes.

[root@linuxhelp1 ~]# vim /etc/phpPgAdmin/config.inc.php
// use ' localhost'  for TCP/IP connection on this computer
$conf[' servers' ][0][' host' ] = ' localhost'  
// understand how to change PostgreSQL' s pg_hba.conf to enable
// passworded local connections.
$conf[' extra_login_security' ] = false 
// not in any way prevent your users from seeing other database by
// other means. (e.g. Run ' SELECT * FROM pg_database'  in the SQL area.)
$conf[' owned_only' ] = true 

Utilise the following command to restart the postgresql and apache services.

[root@linuxhelp1 ~]# systemctl restart postgresql-9.4.service
[root@linuxhelp1 ~]# systemctl restart httpd

Open the browser and navigate to http://< IP_address> /phpPgAdmin
Installation-PostgreSQL9.4-phpPgAdmin-CentOS-Open-browser
Login with user credentials.
Installation-PostgreSQL9.4-phpPgAdmin-CentOS-user-credentials

If any error occurs while login, then run the following command.

[root@linuxhelp1 ~]# setsebool -P httpd_can_network_connect_db 1

phpPgAdmin dashboard appears.
Installation-PostgreSQL9.4-phpPgAdmin-CentOS-phpPgAdmin-dashboard
Installation-PostgreSQL9.4-phpPgAdmin-CentOS-create-database

Tags:
noah
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

How do I change the sort ordering of textual data in PostgreSQL?

A

PostgreSQL sorts textual data according to the ordering that is defined by the current locale, which is selected during initdb.

Q

How does PostgreSQL use CPU resources?

A

The PostgreSQL server is process-based (not threaded). Each database session connects to a single PostgreSQL operating system (OS) process. Multiple sessions are automatically spread across all available CPUs by the OS.

Q

How do I control connections from other hosts?

A

, PostgreSQL only allows connections from the local machine using Unix domain sockets or TCP/IP connections. Other machines will not be able to connect unless you modify listen_addresses in the postgresql.conf file, enable host-based authentication by modifying the $PGDATA/pg_hba.conf file, and restart.

Q

Why phpPgAdmin ask me to re-enter login information for every page I access?

A

You most certainly have a problem with your PHP sessions. Make sure:
your browser accept cookies if your session ID relies on them
PHP has write access to the path set in the parameter “session.save_path” of your php.ini

Q

What happened to the database dump feature in phpPgAdmin?

A

You need to configure phpPgAdmin (in the config.inc.php file) to point to the location of the pg_dump and pg_dumpall utilities on your server. Once you have done that, the database export feature will appear.

Related Tutorials in How to Install PostgreSQL 9.4 And phpPgAdmin in CentOS

Related Tutorials in How to Install PostgreSQL 9.4 And phpPgAdmin in CentOS

How To Install AnyDesk on Centos 7
How To Install AnyDesk on Centos 7
Apr 2, 2018
How to install Tiki Wiki CMS Groupware on CentOS 7
How to install Tiki Wiki CMS Groupware on CentOS 7
May 31, 2018
How to install PHP ImageMagick on CentOS 7
How to install PHP ImageMagick on CentOS 7
Nov 4, 2017
How to Upgrade and Downgrade the PHP Versions on CentOS 7.6
How to Upgrade and Downgrade the PHP Versions on CentOS 7.6
Jun 4, 2019
How to install Apache from Source Code on CentOS 7
How to install Apache from Source Code on CentOS 7
Oct 21, 2017
How to enable or disable repositories in CentOS
How to enable or disable repositories in CentOS
Mar 28, 2018
How to install AWStats on CentOS 7
How to install AWStats on CentOS 7
Dec 8, 2017
How to install Apache JMeter in CentOS 7
How to install Apache JMeter in CentOS 7
Mar 24, 2017

Related Forums in How to Install PostgreSQL 9.4 And phpPgAdmin in CentOS

Related Forums in How to Install PostgreSQL 9.4 And phpPgAdmin in CentOS

CentOS
connor class=
How To Completely Remove Apache package On CentOS 7.6
May 14, 2019
CentOS
ceriaimmaculate class=
setfacl : command not found
Jan 3, 2018
CentOS
mason class=
Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
Nov 20, 2018
CentOS
landon class=
Command to find SNMP Version
May 28, 2018
CentOS
arjitharon class=
cannot start minio service help
Mar 10, 2018
Apache tomcat
AadrikaAnshu class=
Cannot find ./catalina.sh The file is absent or does not have execute permission This file is needed to run this program
Jun 17, 2019
gitlab
caden class=
Insufficient space in download directory /var/cache/yum/x86_64/6/base/packages
Jul 22, 2019
OpenVAS
frank class=
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Dec 20, 2018

Related News in How to Install PostgreSQL 9.4 And phpPgAdmin in CentOS

Related News in How to Install PostgreSQL 9.4 And phpPgAdmin in CentOS

Amazon Web Services offers Aurora Cloud DB accordant with PostgreSQL
Amazon Web Services offers Aurora Cloud DB accordant with PostgreSQL
Oct 27, 2017
Security breach in Indiana Pacers Database
Security breach in Indiana Pacers Database
May 24, 2019
GandCrab Ransomware Infection Made by Scanning MySQL Databases
GandCrab Ransomware Infection Made by Scanning MySQL Databases
May 28, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Jayce ?
What are the types of table used in IPtables

What are the various types of table used in IPtables and how to use that for my server security?

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.