Install PostgreSQL and phpPgAdmin in Windows with Wamp

Category: 

All the PHP developers out here, who use Windows is familiar with WAMP. I the WAMP stack we get a lot of packages like sqlbuddy and phpmyadmin. But a project came to me that uses PostgreSQL. So I had to install PostgreSQL in Wamp. Well it was a tricky job to do. At last I did it. So today in this topic I am going to share this with the developers who need to use PostgreSQL in Windows and Wamp.

In this article I am going to use,

  1. WampServer 2.1. Download it from Here.
  2. PostgreSQL 9.1. Download it from Here.
  3. phpPgAdmin 5.0.2. Download it from Here.

It is assumed that, you have installed the WampServer already. Now, let us proceed with the new Installations.

  1. First, install the PostgreSQL. It is a simple installation procedure. Just click Next Until, when you come to the screen where you give the installation directory. Make it to your suitable directory. I installed it in "C:\wamp\apps\PostgreSQL". Then provide the Data path according to "C:\wamp\apps\PostgreSQL\9.1\data".
  2. Then you will be presented a Password Screen where you can give the main login password. I have made it as "root".
  3. Then in the next screen you will be prompted with the Port number. Make sure it does not conflict with the MySQL port 3306. So I used the default as 5432.
  4. Set the Locale as the Default Locale.
  5. Now click on Next and it will start the installation.
  6. Next click on Finish. And we are done with the installations.
  7. Check installation of PostgreSQL by clicking Start ->Programs ->PostgreSQL 9.1 ->PgAdmin III.
  8. Click on Server(1) and Right Click on PostgreSQL Database Server 9.1 (localhost:5432) and Select Connect to obtain a connection to server and give password. It will connect to Database server.
  9. Now it is time to bridge PHP to it. So Go on the task bar and Left Click on the Wamp Tray icon. Navigate to PHP > PHP extension. Then enable,
    1. php_pgsql
    2. php_pdo_pgsql extension.
  10. Restart the Wampserver. This time you will probably see some errors saying like,
    1. PHP Warning:  PHP Startup: Unable to load dynamic library  'C:\wamp\bin\php\php5.3.5\ext\php_pdo_pgsql.dll' - The specified module could not be found.
    2. PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\wamp\bin\php\php5.3.5\ext\php_pgsql.dll' - The specified module could not be found.
  11. To eleminate them you need to copy libpq.dll from wamp\bin\php\php5.3.5 to  wamp\bin\apache\Apache2.2.17\bin. Again restart the Wamp Server. By now we are done with the php configuration. Next we will install phpPgAdmin and use it.
  12. So download phpPgAdmin and copy it in C:\wamp\apps assuming, Wampserver is in C Drive. So the path will be, C:\wamp\apps\phpPgAdmin-5.0.2.
  13. To make a shortcut in Wamp Index page in the Your Aliases section create a file called, phppgadmin.conf in C:\wamp\alias. And copy paste the following,
    Alias /phppgadmin "C:/wamp/apps/phpPgAdmin-5.0.2/" 
     
    <Directory "C:/wamp/apps/phpPgAdmin-5.0.2/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
            Order Deny,Allow
    	Allow from all
    </Directory>
  14. Restart the Wamp server and go to http://localhost/. You will see a link came under Your Aliases  as phppgadmin. Click on that link and you will see the following screen.
    Login phppgadmin
  15. Then click on the PostgreSQL link on the left hand side. You will be prompted for the username and the password. By default postgrey creates an user called postgres. So give it in the username field and give the password same as you have entered in the time of the installation. For me it is root.
    pgadmin login username and password
  16. Last we will see the following screen after successful login.
    phppgadmin database browser screen
  17. Last is is time to test a simple database connection PHP script. So to do that, create a database called test and create a php page with the following code in it.
    <?php
    $con="host=localhost port=5432 dbname=test user=postgres password=root";
    $db=pg_connect($con) or die('connection failed');
    echo 'Connected to: ', pg_dbname($db);
    ?>

     
    If it does not show any error, then we are good to go. We can use PostgreSQL.

  18. If you face any problem then you can write to me. I will try to solve the problem.

Rate this content: 

Average: 4 (29 votes)

Comments

Error

I got this error after clicking on the alias
and
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\wamp\bin\php\php5.3.5\ext\php_pgsql.dll'
exists even after copying that file

error

after i open phppgadmin in the localhost and then try to login error ''Login disallowed for security reasons" appears. i dont know where the problem is , please help

EasyPHP

Hello,

Thanks very much to you because of your explanations for WAMP I was able to make my Easy-php 5.4.0 -Installation working. (Sorry that I prefere Easyphp). No one on the forum wanted to help me so it was your article, another article which help me to do this...

thommy7571

Great Clear and efficient tuto !

Hi thomas,
Thanks very much for this clear tuto,
I needed a simple Window install to start dev. with Postgresql.
*except for the late extra_login_security lately modif.
everything went fine.
Runing phpPgAdmin vers. 5.0.3 in Wampserver 2.2 on XP.
Cool !

installing phppgadmin in wamp

Hey.
m had followed all mentioned steps upto step 14.
but as mentioned in step 15 i am not getting POSTgreSQL link. i.e no username and password prompted :(
this error arises when i click postgresql link
"Your PHP installation does not support PostgreSQL. You need to recompile PHP using the --with-pgsql configure option"

Login failed...

When I am using postgres as username and root as my password it shows the error:
"Login disallowed for security reasons.".
Provide some help....!!!!

Error in login of PostgresSQL

Error: in STEP 15:
When I am providing the username and password as
postgres & root
(namely...)
But it shows error
"Login disallowed for security reasons."
Provide Some help...!!!

You don't have permission to access /pgsql/ on this server.

i always got this message :"'You don't have permission to access /pgsql/ on this server" every time when i clicked on the phppadmin link in the local host page. the phppgadmin link below alias work perfectly but the on below tools doesnt, and it s doing the same thing for pgsl. can you help me please.

undefined function pg_connect()

Hi! I'm having problems connecting to the database using the php script above... It shows this error "Fatal error: Call to undefined function pg_connect() in C:\wamp\www\sample.php on line 3" can you please help me... Thanks!

Thank you!

Thank you for this very useful page. I am complete novice to web development using wamp 2.2 server.
This article helped me set up my wamp server, pgsql and phppgadmin.

one tip would be to spell out where to place the .php file and how to access it after the "create a php page with the following code in it...." step. I had to spend some time learning how to deploy a php script before i could figure that one out.

I ultimately learnt that it goes in the www folder under /wamp/www and it can be opened by pointing a browser to the url: localhost/testpgsql.php (i named the php script testpgsql.php).

overall, very useful article - also some useful comments and follow-up responses to resolve issues such troubleshooting the login error ''Login disallowed for security reasons"

thanks

"Not" using PHPpgMyAdmin

First off, great article. Since we need to have pgAdmin III running to have the server up and running, I have found it to be useless to download and install PHPpgMyAdmin, since it does the exact same thing as pgAdmin. Plus I think it's hard to argue that the performance of the desktop app will always be better than the one running in the browser. So... yeah...

I got errors

( ! ) SCREAM: Error suppression ignored for
( ! ) Strict standards: Only variables should be assigned by reference in C:\wamp\apps\phpPgAdmin-5.0.4\classes\database\Connection.php on line 23
( ! ) SCREAM: Error suppression ignored for
( ! ) Strict standards: Only variables should be passed by reference in C:\wamp\apps\phpPgAdmin-5.0.4\redirect.php on line 14
Call Stack

i got this kind of errors..what should i do?? thank you

Log In issue

Hey i have set password 'postgres', while installing postgres9.1. After all setup completed i enter 'http://localhost/phppgadmin/' it asks username and password. I entered postgres for both username and password but it is coming like login is not allowed. Please help me regarding this

Add new comment