How to install PostgreSQL and phpPgAdmin
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.
For most versions this should work straight away. I have tested it on Ubuntu 16.04.1
Things we will learn in this tutorial
- Installing PostgreSQL & phpPgAdmin on a Linux Machine
- Configuring the above two packages/software
Note: TROUBLESHOOTING links have been mentioned in the tutorial. So give it a read to save some time in case error occurs.
Steps for installation
- 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
.
3. To allow logging into phpPgAdmin using postgres
user, tweak some setting of phpPgAdmin
cd /etc/phppgadmin
sudo vi config.inc.php
Set $conf['extra_login_security']
from true
to false
.
4. Restart the services
sudo service apache2 restart
sudo service postgresql restart
5. Open browser and go to the following url
localhost/phppgadmin
The following screen should be showing up.
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
# Quit postgres
\q
Now you may login at localhost/phppgadmin
Suggested Read
- https://askubuntu.com/questions/376199/sudo-su-vs-sudo-i-vs-sudo-bin-bash-when-does-it-matter-which-is-used
- https://serverfault.com/questions/110154/whats-the-default-superuser-username-password-for-postgres-after-a-new-install
- https://zaiste.net/posts/postgresql_primer_for_busy_people/