PostgreSQL with XAMPP

If your like me, somewhat lazy you setup your webserver with the help of XAMPP. Then a few months down the track your faced with accessing a PostgreSQL database instead of the more common MySQL database.

Well much to your and my relief it’s actually quite a simple process that only takes about 10 minutes of stress.

I remember when I first configured it I found a really good blog with the instructions, but I lost the link to it so I never got the chance of bookmarking it. I’ve since found out how to setup PostgreSQL and will hopefully give you an idea of how to install it.Setup PostgreSQL with XAMPP

Download the PostgreSQL Binary from Enterprisedb.com the version I’ve installed is 9.2.4. Download either the x86-32 or x86-64 binary depending upon your system’s properties.

While that’s downloading we’ll prepare the extensions in in your php.ini file.

Un-hide the following two lines in the extension area of your php.ini file:

extension=php_pgsql.dll
extension=php_pdo_pgsql.dll

Now the final manual configuration step is adding the path to PostgreSQL in your system’s environmental variables.

Right click My Computer > Select Properties. Click on the Advanced tab and then Environment Variables. In the System Variables section where the PATH variable is listed double click on it’s value area. Add the following to the end (don’t forget the following ‘;’)

C:\XAMPP\PostgreSQL\bin;

Environment Variables PostgreSQL

Now that we have all the manual configurations done we just need to install that file we downloaded.

Run the the download except make the following two changes to it’s installation folder and data folders.

The Installation folder: C:\xampp\PostgreSQL
The data folder be: C:\xampp\PostgreSQL\data

Once completed if you make these changes in Windows 7 all you need to do is restart your Apache service otherwise if you don’t know how to do this or if you use Windows XP restart your machine.

The final step is to make sure it’s all up and running. To verify log into your XAMPP for windows control panel¬†https://localhost/xampp/.¬† Then click on the phpinfo() on the left sidebar. You should then see a section with pdo_pgsql and pgsql. if you can see these headings then you’ve successfully installed PostgreSQL.

PostgreSQL XAMPP

Don’t worry if you can’t work out how to find your XAMPP control panel, just create a php file within your htdocs folder and add the following to it: It should then load up phpinfo().

phpinfo.php

<?php
phpinfo();
?>