PostgreSQL on Ubuntu with phpPgAdmin

Setting up default installations of Apache, PHP and PostgreSQL is really easy, I’m using a Gutsy setup and writing this in a terminal:


sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install postgresql

Next we should setup a new PosgreSQL user, entering psql in a terminal will get you into the PostgreSQL session interface. Enter the following there:

CREATE USER henrik WITH PASSWORD '1234';
ALTER ROLE henrik SUPERUSER;
\q

Don’t forget the semi colons!

If you get psql: FATAL: database “root” does not exist you:
1.) Switch user to postgres: # su - postgres
2.) $ createuser (followed by the name of the role to add and superuser y/n : y)
3.) $ createdb dbname (optional, you could do this later in phpPgAdmin)
4.) You might have to do ALTER ROLE henrik WITH PASSWORD ‘1234′; in psql.

Back in the “normal” terminal:
sudo gedit /etc/postgresql/8.2/main/pg_hba.conf

Add
local all all trust
to the file.

Download phpPgAdmin.

In the terminal
sudo chmod 777 /var/www

Extract the downloaded file into /var/www/phppgadmin.

Restart both Apache and PostgreSQL:

sudo /etc/init.d/apache2 restart
sudo /etc/init.d/postgresql-8.2 restart

In Firefox:
localhost/phppgadmin/

Use henrik (or whatever you used instead) as login with empty password (not if you set the password to 1234 like I did above of course), voila!

I tried to use phpPgAdmin about a year and a half ago and it felt really crude, not now though, really awesome, it’s like having pgAdminIII integrated in the browser!

Related Posts

Tags: , ,