Skip to content

How to install PostgreSQL and phpPgAdmin

This tutorial should work on most of the Ubuntu versions, I have tested it on Ubuntu 18.04

PostgreSQL is a powerful open-source database management system. Its basically a software that manages your database.

phpPgAdmin is a software that allows you to control PostgreSQL via a Graphical User Interface.

Steps for installation

  1. Installing the right softwares
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib 
sudo apt-get install apache2 phppgadmin

2. Configuring Apache2

In order to access phpPgAdmin via your browser, the Apache web server needs to be configured. Therefore open the phppgadmin.conf file:

cd /etc/apache2/conf-available/
sudo vi phppgadmin.conf

Comment out the line Require Local and add Allow from all .

Before editing /etc/apache2/conf-available/phppgadmin.conf
After editing /etc/apache2/conf-available/phppgadmin.conf

3. To allow logging into phpPgAdmin using postgres user, tweak some setting of phpPgAdmin

cd /etc/phppgadmin
sudo vi

Set $conf['extra_login_security'] from true to false.

Before editing /etc/phppgadmin/
After editing /etc/phppgadmin/

4. Restart the services

sudo service apache2 restart
sudo service postgresql restart

5. Open browser and go to the following url


The following screen should be showing up.

localhost/phppgadmin homepage

Congratulations on successful INSTALLATION of the above softwares. To actually use them, we need to configure the postgreSQL user.

Steps for Logging into postgreSQL using phpPgAdmin

Now the phpPgAdmin is asking for a login and a password. Hmm..what’s this shit??? I will try to explain in detail.

PostgreSQL uses concept of role (or simply users) to use the DBMS, i.e. to use postgreSQL you have to log in into this software, same as you need to do in an operating system.

It comes with a default user called postgres that is locked by default to prevent unintentional logging in.

To log in into postgres account, we need to set up its password. Follow the steps.

# Run psql command as postgres user created during 
# installation automatically
sudo -u postgres psql
# Set the password
Password prompt screen to set the password using postgres shell
# Quit postgres

Now you may login at localhost/phppgadmin

Published inLinux