There is a new version of this tutorial available for Ubuntu 20.04 (Focal Fossa).

How to Install Postgresql and phpPgAdmin on Ubuntu 15.04

PostgreSQL or Postgres is a powerful high-performance object-relational database management system (ORDBMS) released under a flexible BSD-style license. PostgreSQL is well suited for large databases and has many advanced features.

PostgreSQL is available for many operating systems including Linux, FreeBSD, Solaris, and Microsoft Windows.

PhpPgAdmin is a PHP based web application for managing PostgreSQL databases. With Phppgadmin, it is easy to create a database, create a role and create tables in Postgres.

This tutorial will show the installation of PostgreSQL and its web-based administration interface phpPgAdmin on Ubuntu 15.04.


  • Ubuntu Server 15.04.
  • Root/Sudo access.

What we will do in this tutorial:

  1. Install PostgreSQL, phpPgAdmin and Apache2.
  2. Configure a PostgreSQL User.
  3. Configure Apache2.
  4. Configure phpPgAdmin.
  5. Testing.

Step 1 - Installing PostgreSQL, phpPgAdmin and Apache2

PostgreSQL and PhpPgAdmin are available in the Ubuntu repository. So you just need to install them with the apt command.

sudo apt-get install postgresql postgresql-contrib phppgadmin

The above command will automatically install all packages needed by PostgreSQL, like Apache, PHP etc.

Step 2 - Configure PostgreSQL user

PostgreSQL uses role for user authentication and authorization, it just like Unix-Style permissions. By default, PostgreSQL creates a new user called "postgres" for basic authentication. To use PostgreSQL, you need to login to the "postgres" account, you can do that by typing:

sudo su
su - postgres

Now you can access the PostgreSQL prompt with the command:


And then change the password for postgres role by typing :

\password postgres


Setting User PostgreSQL

Step 3 - Configure Apache2

You need to configure apache for phpPgAdmin. Edit the file /etc/apache2/conf-available/phppgadmin.conf with nano by typing:

cd /etc/apache2/conf-available/
nano phppgadmin.conf

Comment out the line #Require local by adding a # in front of the line and add below the line allow from all so that you can access from your browser.

Allow All User

Step 4 - Configure phpPgAdmin

Edit the file /etc/phppgadmin/ by typing :

cd /etc/phppgadmin/

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

Enable Login Web Base

Step 5 - Restart PostgreSQL and Apache2

systemctl restart postgresql
systemctl restart apache2

Step 6 - Testing

Now access phppgadmin with your browser http://yourip/phppgadmin/.


and then try login to with user postgres and your password.

Login with Postgres

After logging in you will get this interface:

After Login


PostgreSQL is an advanced object-relational database management system (ORDBMS), it is Open Source and has a large and active Community. PostgreSQL provides the psql command line program as primary front-end, which can be used to enter SQL queries directly, or execute them from a file. phpPgAdmin is a web-based administration tool for PostgreSQL written in PHP that make the administration of Postgres databases easier.

Share this page:

Suggested articles

6 Comment(s)

Add comment


By: jura12


By: Ruben Cardenas

Thanks, it helps me a lot

By: Efren Hdez

I am have a connection error with php

/****************CONNECTION PHP************************/

$user = 'postgres';$passwd = 'efren';$db = 'pruebaphp';$port = 5432;$host = 'localhost';$strCnx = "host=$host port=$port dbname=$db user=$user password=$passwd";$cnx = pg_connect($strCnx) or die ("connection error. ". pg_last_error());echo "Connection succefull


/*******************Configuration fil****************/



# Database administrative login by Unix domain socketlocal   all             postgres                                md5# TYPE  DATABASE        USER            ADDRESS                 METHOD# "local" is for Unix domain socket connections onlylocal   all             all                                     md5# IPv4 local connections:host    all             all             localhost               md5# IPv6 local connections:host    all             all             ::1/128                 md5




By: Krys

Great tutorial, works fine. Thanks

By: arvind

psql command is not the error  :

psql: could not connect to server: No such file or directory    Is the server running locally and accepting    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

By: Hugo Gonzalez

Thank you, very useful. It is a good start for me. I am Manager Oracle Database and this helps me supplement . I am very interested Free Software. This is very simple and based on this construire more and more experience. Thank you so much Regards,

Hugo gonzalez

Caracas, Venezuela.