How to Install PostgreSQL and phpPgAdmin in Ubuntu

To Install PostgreSQL and phpPgAdmin in Ubuntu

PostgreSQL is a powerful high-performance, object-relational database management system (ORDBMS). It is well suited for large databases and has a quite large advanced features. It supports many OS that includes Linux, FreeBSD, Solaris and Microsoft Windows.

PhpPgAdmin is a PHP-based web application, used for managing PostgreSQL databases. It is easy to create a database, create a role and create tables in Postgres.

In this tutorial will learn how to install PostgreSQL and phpPgAdmin in Ubuntu.


To install PostgreSQL, phpPgAdmin and Apache2

PostgreSQL and PhpPgAdmin are available in the Ubuntu repository, just install them by using the following command.

root@linuxhelp:~# apt-get install postgresql postgresql-contrib phppgadmin
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2 apache2-bin apache2-data apache2-utils javascript-common libapache2-mod-php libapache2-mod-php7.0
libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjs-jquery liblua5.1-0 libphp-adodb libpq5
php-common php-pgsql php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-pgsql php7.0-readline
postgresql-9.5 postgresql-client-9.5 postgresql-client-common postgresql-common postgresql-contrib-9.5
postgresql-doc postgresql-doc-9.5 sysstat
Suggested packages:
.
.
.
Processing triggers for ufw (0.35-0ubuntu2) ...
Processing triggers for libapache2-mod-php7.0 (7.0.8-0ubuntu0.16.04.3) ...


To configure PostgreSQL user, Apache

Now its time to start PostgreSQL. Set the database and database username as and like Unix. To do so, login to the " postgres" account by running the following command.

root@linuxhelp:~# su &ndash  postgres

Now you can access the PostgreSQL prompt with the command.

postgres@linuxhelp:~$ psql
psql (9.5.4)
Type " help"  for help.

postgres=#

Execute the following command to change the password for postgres.

postgres=# password postgres
Enter new password:
Enter it again:
postgres=#
Then enter q to leave the psql command line.
postgres=# q

Leave the postgres user to switch over as root user.

postgres@linuxhelp:~$ exit
logout

To configure the Apache for phpPgAdmin, edit the phppgadmin.conf as shown below.

root@linuxhelp:~# cd /etc/apache2/conf-available/
root@linuxhelp:/etc/apache2/conf-available# vim phppgadmin.conf

Enter ' #' in front of the line ' Require local' and add the new line " allow from all" to access the browser.

To configure phpPgAdmin, edit the file /etc/phppgadmin/config.inc.php with the following command.

root@linuxhelp:/etc/apache2/conf-available# cd /etc/phppgadmin/
root@linuxhelp:/etc/phppgadmin# vim config.inc.php

Find the line $conf[' extra_login_security' ] = true and change the value to ' false' so that you can login to phpPgAdmin with user postgres.

Now its time to restart PostgreSQL and Apache2.

root@linuxhelp:/etc/phppgadmin# systemctl restart postgresql
root@linuxhelp:/etc/phppgadmin# systemctl restart apache2

Open the browser and enter http://yourip/phppgadmin/ to access phppgadmin.

Login with user postgres and password.

Now its time to create a database, a role and tables in Postgres.

FAQ
Q
How does PostgreSQL compare to MySQL?
A
This is a topic that can start several hours of discussion. As a quick summary, MySQL is the "easy-to-use, web developer" database, and PostgreSQL is the "feature-rich, standards-compliant" database. PostgreSQL is liberally licenced and owned by its community; MySQL is GPL-licenced and owned by Oracle. Beyond that, each database user should make his own evaluation; open source software makes doing comparisons very easy.
Q
Who controls PostgreSQL?
A
If you are looking for a PostgreSQL gatekeeper, central committee, or controlling company, give up --- there isn't one. We do have a core committee and git committers, but these groups are mo
Q
Does PostgreSQL can run on the Cloud?
A
Yes. Like other open source databases, PostgreSQL is easy to run in both containers and virtual machines and is highly portable. Many companies have support for PostgreSQL in cloud hosting environments, including Heroku, Amazon, VMware, Compose.io, EnterpriseDB, Red Hat, Microsoft, and Google.
Q
When I drop and re-create a table with the same name, it fails.how to sove it?
A
You need to drop the sequence attached to the SERIAL column of the table as well. PostgreSQL 7.3 does this automatically. If you have upgraded to PostgreSQL 7.3 from an earlier version, you n
Q
Where can I get PostgreSQL?
A
There are binary distributions for various operating systems and platforms; see our download area.

The source code can be obtained via web browser or through ftp