phpPgAdmin On Linux On Windows With Vagrant

This tutorial is a continuation of Rails On Linux On Windows With Vagrant.

What we want to achieve at the end of this tutorial is to able to modify our PostgresSQL database from a convenient web interface (phpPgAdmin) directly from the web browser in our host machine. Observe:

2015-09-18 21_19_47-phpPgAdmin

Let’s roll:

Port Forwarding

For this to work, we need to forward the port 80 in our guest machine to port 8080 in our host.

If you are in SSH mode, exit it by entering


Then halt it:

vagrant halt

In the Vagrantfile in your project directory, uncomment the following line: "forwarded_port", guest: 80, host: 8080

Though not apparent in the Vagrantfile here, the virtual machine we used forwards port 3000 in the guest machine to port 3000 in the host machine. That is how we are able to access our Rails application from the host machine. You can find it here:


In “_Vagrantfile” (the only file in that directory), you can peek in its contents:

Vagrant.configure(2) do |config| "forwarded_port", guest: 3000, host: 3000

Install phpPgAdmin

After you have ran vagrant up and vagrant ssh, in git bash enter:

sudo apt-get update
sudo apt-get install phppgadmin

Congratulations! You have installed phpPgAdmin, but when you go to its URL – http://localhost:8080/phppgadmin/ (make sure its all in lower case), you get a page not found error:

2015-09-18 20_46_29-404 Not Found

It’s not all bad. At least we know Apache Server is running.

Setup phpPgAdmin

So now we need to configure Apache server to tell it where to find phppgadmin. Edit /etc/apache2/apache2.conf

sudo nano /etc/apache2/apache2.conf

and add the following line to it:

Include /etc/apache2/conf.d/phppgadmin

If you’re not familiar with nano, just press the down key till you reach the end of the document. Copy paste the line above and press Ctrl-O (save), Enter (confirm overwrite), followed by Ctrl-X (exit).

When you have done this, restart apache:

sudo service apache2 reload

Now when you try to access phppgadmin (http://localhost:8080/phppgadmin/). The error message changes:

2015-09-18 20_54_01-403 Forbidden

Basically its trying to say that phppgadmin is there, it’s just that you don’t have permission to access it. So let’s change that now. Enter:

sudo nano /etc/apache2/conf.d/phppgadmin

Comment out (add # at beginning of line) “allow from ::1/128” and remove # from the line below it, “allow from all”. Your file should look like this:

order deny,allow
deny from all
# allow from ::1/128
allow from all

Save it out and restart apache again, now try to access phppgadmin again. You should be able to see the site now. Though it’s not apparent what you should be doing (contradictory to a more user-friendly web client, phpMyAdmin), click “PostgreSQL”:

2015-09-18 21_01_07-phpPgAdmin

…and it prompt for your login. What’s the username and password? Default username is postgres, but you need to set a password. Let’s do that now. Enter:

sudo -u postgres psql postgres

That should take you to psql:

2015-09-18 21_09_35-MINGW64__d_HashiCorp_Boxes_vagabond

To set a password enter:

\password postgres

It will prompt you for the password, which you will not be able to see it as you type. This will be the password you will use to login to phppgadmin.

To quit psql, enter:


If you try to login now, it will block you with the message:

Login disallowed for security reasons.

Well, we’re not so bothered about security reasons at the moment, so in git bash enter:

sudo nano /etc/phppgadmin/

and change

$conf['extra_login_security'] = true;


$conf['extra_login_security'] = false;

and try to login to phppgadmin again (again, username is postgres). It should work now.

Troubleshooting PostgreSQL

You might encounter this FATAL: role “vagrant” does not exist error:

FATAL role vagrant does not exist Action Controller_ Exception caught

To fix the vagrant role problem, enter this code in ssh mode (make sure you shut down your rails server first):

sudo -u postgres createuser -s -d -r -e vagrant

That should resolve that issue. Note that you need to execute all postgres commands the same way (prefix “sudo -u postgres“). For example:

sudo -u postgres createdb TimeTabler_development

You may also realize that you also can’t access the psql for the exact same error. To work around this, access psql like this:

sudo -u postgres psql postgres

You exit the terminal as such:



Once you’re done playing around, you can halt the virtual machine by first exiting SSH, then halt the virtual machine:

vagrant halt



One thought on “phpPgAdmin On Linux On Windows With Vagrant

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s