How to Install PostgreSQL and phpPgAdmin on Ubuntu

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 -y 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


Then enter \q to leave the psql command line.


exit the postgress user and come back to root or other sudo enabled user

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.


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.