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,
- WampServer 2.1. Download it from Here.
- PostgreSQL 9.1. Download it from Here.
- 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.
- 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".
- Then you will be presented a Password Screen where you can give the main login password. I have made it as "root".
- 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.
- Set the Locale as the Default Locale.
- Now click on Next and it will start the installation.
- Next click on Finish. And we are done with the installations.
- Check installation of PostgreSQL by clicking Start ->Programs ->PostgreSQL 9.1 ->PgAdmin III.
- 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.
-
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,
- php_pgsql
- php_pdo_pgsql extension.
-
Restart the Wampserver. This time you will probably see some errors saying like,
- 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.
- 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.
- 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.
- 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.
-
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> -
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.
-
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.
-
Last we will see the following screen after successful login.
-
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. - If you face any problem then you can write to me. I will try to solve the problem.
Comments
Error
Submitted by Kiguhu (not verified) on
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
To solve the Error
Submitted by aneek on
Hello Kiguhu,
To solve it you need to do the following,
Copy libpq.dll from wamp\bin\php\phpX.X.X to wamp\bin\apache\ApacheX.X.XX\bin
Here all the X's represent your package's versions.
error
Submitted by mija (not verified) on
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
How to disable the login sesurity
Submitted by aneek on
Hello Mija,
I hope it can be solved by the following tweak.
Locate the phppgadmin's config.inc.php then search for $conf['extra_login_security']. Once you find it make it as,
$conf['extra_login_security'] = false;
I hope it will solve your problem. Do write to me if it's not solved.
EasyPHP
Submitted by thommy7571 (not verified) on
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
Thanks thommy,
Submitted by aneek on
Thanks thommy,
I really appritiate that my tutorial came handy for you.
I got the error like this
Submitted by mukunda (not verified) on
I got the error like this "You don't have permission to access /phppgadmin/ on this server."
Also get Warning message "Module_pgsql already loaded
Allow all or directory exists
Submitted by aneek on
Hello,
Probably you haven't gave permission to AllowOverride to All and check your directory location. Also check the file in the alias folder.
Please let me know if the problem is still there.
I have the same problem. The
Submitted by cns (not verified) on
I have the same problem. The following error:
Forbidden
You don't have permission to access /phppgadmin/ on this server.
Could you explain i detail what should be done?
Allow Override
Submitted by aneek on
Enable Allowoverride in your virtual host. Then try it again after restarting the Apache server.
Great Clear and efficient tuto !
Submitted by Eric (not verified) on
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
Submitted by Jiya rehman (not verified) on
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...
Submitted by Sauss (not verified) on
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
Submitted by Sauss (not verified) on
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...!!!
Login Disabled
Submitted by aneek on
Dear Sauss,
Sorry for the late reply,
To solve it do the following,
Locate the phppgadmin's config.inc.php then search for $conf['extra_login_security']. Once you find it make it as,
$conf['extra_login_security'] = false;
let me know if this one solved your problem or not.
You don't have permission to access /pgsql/ on this server.
Submitted by cknet (not verified) on
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.
I didn't got you..
Submitted by aneek on
Dear cknet,
Can you please tell me in detail, which problem you are facing.
1. Are you having problem to open phpMyadmin?
2. Which tools are you talking about?
Please let me know. I will surely help you to solve your problem.
Thanx Dude it works fine
Submitted by faris (not verified) on
Thanx Dude it works fine
Sweet. Wanted to try out
Submitted by Blah (not verified) on
Sweet. Wanted to try out PostgreSQL for some time. phpPgAdmin is going to be a bit of a learning curve. Recommend any tutorials? Thanks in advance.
undefined function pg_connect()
Submitted by Nath (not verified) on
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!
Already written
Submitted by aneek on
Hello Nath,
Please go with the comments, you will find the answers I guess.
Thanks
Submitted by Samrat Gavale (not verified) on
Thanks for your solution to "Login disabled for security reasons." It helps!
Thank you!
Submitted by Ani (not verified) on
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
Submitted by Rodrigo Silveira (not verified) on
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
Submitted by syazwan (not verified) on
( ! ) 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
programming tutorial
Submitted by toriq bagus (not verified) on
Thanks very much to you because of your explanations for WAMP I was able to make my Easy-php 5.4.0 -Installation working.
It worked For Me
Submitted by Amar Gurung (not verified) on
Really for 3 days i was breaking my head finally went through this link.
Thanks:)
Log In issue
Submitted by vinay (not verified) on
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
Thanks so much for you page,
Submitted by Ale (not verified) on
Thanks so much for you page, it helped me a lot.
Add new comment