Skip to content

Adding PostgreSQL portable to XAMPP (on Windows)

For those who don’t know it, XAMPP is a package containing the main things you need to setup and run a local webserver within a few minutes (configured as a testing/dev platform, not a production platform). I used to be reluctant to using it, but I eventually found out that the Lite version used without the installer was really useful, notably on PCs where I don’t have admin rights. XAMPP has a few limitations, though. Notably, there’s no PostgreSQL (even in the “not-Lite” version). So, here’s how to add PostgreSQL to XAMPP Lite (or not Lite).


First, get PostgreSQL portable here (topic on portable freeware).
Edit: unfortunately that link seems to be down and I didn’t keep a copy of the installer… :/ If you find one, please do post the link in a comment. However, it should be possible to make the non-portable version of PostgreSQL work with XAMPP just the same way as for the portable version (see below).
Update: PostgreSQL provides a binary download which can be used as a portable version. You can grab it here. I haven’t tried it yet, but I guess my instructions don’t apply to this version… I’ll update them some day…
Unzip it anywhere you want, then launch PostgreSqlPortable.exe. At first you’ll need to initialize the database: click on “Initialize PostgreSQL 8.3”, choose a user name (you can leave the default on, I chose “root”), a password and the port (leaving the default 5432 is good, it will let you configure phpPgAdmin faster). The database initialization will then take a few seconds (over 15 seconds on my very slow PC…). Then click on “Start PostgreSQL 8.3”. On a restricted computer, you may get an error message “Error starting PostgreSQL”. This seems to be an issue on the launcher: PostgreSQL is probably still running successfully (check in the task manager if you see a few running postgres.exe).

Now, all you need is to configure PHP to be PostgreSQL-enabled. In XAMPP’s folder, find php/php.ini and uncomment (or create) the lines extension=php_pgsql.dll and extension=php_pdo_pgsql.dll. Restart Apache and voilà, PostgreSQL is now usable from your XAMPP installation.


phpPgAdmin is to PostgreSQL what phpMyAdmin is to MySQL: every newbie needs it, most power-users enjoy it. It can be downloaded from Extract it in XAMPP’s htdocs folder (e.g. in htdocs/phppgadmin). Copy the default configuration file (conf/ and rename it to conf/ Then in this file edit the following lines:

  • $conf['servers'][0]['host'] = 'localhost';
  • $conf['servers'][0]['defaultdb'] = 'postgres';: not sure if that’s really needed but I configured it this way…
  • $conf['extra_login_security'] = false;: so you can log in as root on the database. Not needed if you chose a custom username as the admin username (during the database initialization process). But I chose root, so leaving it to true gave me the infamous “Login disallowed for security reasons.” error.

Finally, phpPgAdmin triggers a deprecation warning in PHP 5.3. And this deprecation warning is quite misplaced, as you can see from the error it generates:

Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at xampplite\htdocs\phppgadmin\classes\Misc.php:344) in xampplite\htdocs\phppgadmin\libraries\ on line 56

To fix this, you can either:
– fix Misc.php: replace, on line 344, $data =& new $_type($_connection->conn); with unset($data);$data = new $_type($_connection->conn);
– or turn off deprecation notices (NB: not tested): in php.ini, replace error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED with error_reporting = E_ALL & ~E_NOTICE or even error_reporting = 0.

That’s it, you can now access phpPgAdmin at (that is, if you chose the same path as me).

Sources and versions

For this short guide I used:

  • PostgreSQL Portable v1.2.0 (contains PostgreSQL v8.3.7-1), 23 Aug 2009
  • XAMPP Lite 1.7.3 with PHP patched to 5.3.2 (see upcoming tutorial about this)
  • phpPgAdmin 4.2.3, 29 March 2010

Posted in portable software, PostgreSQL, web development.

18 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Thomas says

    thank for he instruction..

    How do I add the “Postgresql” section to the XAMPP control panel so I can start/stop Postgres from Xampp control pannel just like the “MySql” line come after the Apache one.


  2. patheticcockroach says

    Hm, I don’t think that’s easily possible, you’d need to modify the XAMPP control panel and recompile it to do this I believe.

  3. Mubashar Ahmad says

    I have changed the php.ini as suggested but on opening phpPgAdmin it says

    “Your PHP installation does not support PostgreSQL. You need to recompile PHP using the –with-pgsql configure option.”

  4. patheticcockroach says


    Are you sure you didn’t forget to restart Apache after editing php.ini? Also, are you using XAMPP Lite 1.7.3? (the “not Lite” version is somewhat different, although as far as I know it should work with Postgre – I don’t know about version 1.7.4 though)

  5. Mubashar Ahmad says

    Hi thanks for reply,

    Yes I restarted Apache from xampp control panel, even tried I restarted my computer :(. And I am using latest versions of each Xampp (1.7.4), postgresql(9.x), phppgadmin(5.0.2).

    I spent the whole day on this googling and googling around, New to xampp thing, please if you can guide me somehow, I have also checked the path of php.ini from xampp console (phpinfo())

  6. patheticcockroach says

    I just tried to activate that php_pgsql.dll on XAMPP 1.7.4 and indeed it didn’t work. It said something about a missing libpq.dll (“The program can’t start because LIBPQ.DLL is missing from your computer. Try reinstalling the program to fix this problem”), which is particularly weird since that file does exist in the php folder… So then I copied it into apache/bin, and it now seems to work. 🙂
    Note that according to phpinfo() the version of libpg is 8.3.3. I don’t know if that’s supposed to work with PostreSQL 9.x.

  7. Techfanatic says


    Thanks for sharing the solution on LIBPQ.DLL. I would have not figured that out myself.

  8. dacm says


    * PostgreSQL v8.3.7-1 (PostgreSQL Official Site)
    * pgAdmin III v1.8.4 (pgAdmin III Official Site)

  9. Web Hosting says

    Thanks for the libpq.dll trick, that worked nicely!

  10. cat says

    yeah… i was trying to find out how to solve the “missing libpq.dll”… thanks a lot!

  11. Ahmed AbuBakr says

    thanks @patheticcockroach for sharing the solution 🙂

  12. patheticcockroach says

    No problem, I’m just sorry I didn’t keep the installer… :s

  13. deblagoj says

    Thanks @patheticcockroach :)) you saved me

  14. THX says

    thx, patheticcockroach
    One year later You still helps people : )

  15. marvin says

    Thanks PCR.

  16. MaY says

    waaaa this trick with libpq.dll just saved my life 🙂 thankssss 🙂

  17. Anonymous says

    Whoa…this is great.Tried it too and it worked. — Muyiwa

  18. brendan says

    followed the instructions to the letter but keep getting ‘login failed’ and have search what feels like everywhere for the fix to the problem, any ideas ?? 🙁

Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA