Thursday, July 15, 2010

WAMPServer and Apache on Windows: Changing the port number

It all started when I wanted to create an application with MySQL as a backend. Since I am not well versed in MySQL, one of my colleagues suggested that I use phpmyadmin. He had a nice installation of phpmyadmin installed in the tools development server we have in our office and I tried it for sometime. Today morning, I decided to install phpmyadmin in my local machine so that I can work on my application when at home too. But there was no one around who had installed phpmyadmin in Windows. :(

After a few iterations in trying to get PHP, Apache and MySQL to talk to each other in Windows, I realized that I was going nowhere and hence decided to install one of the WAMP applications that are lying around online. I chose WampServer.

After installing WampServer, I noticed that it comes with phpmyadmin pre-installed. :)

Now this is the problem I faced. The default port for Apache as configured in the installation in WAMPServer was 80 and this was already being used by Skype. The following are the steps which I followed to change this port:
1) Left click on the WAMPServer tray icon and choose "Apache".
2) Open "httpd.conf".
3) In the file, search for "Listen 80". The "80" is the current port number.
4) Change it to whichever port number you want it to be. Choose a port that is not already in use.
5) "Restart All Services" by left-clicking on the tray icon again.
I got most of this information from this page.

This brought about another irritating albeit minor problem: If you notice in the image above, there are shortcuts to "Localhost" and "phpmyadmin" in this menu. These still use the port "80". Every time I click on these shortcuts, I get a page not found and then need to change the port.

How do I fix that one? I tried the steps in the page linked above, but that information seemed to be for some other version of WAMPServer.

So, here are the steps I found for WAMPServer Version 2.0:
1) Go to the folder in which you have installed WAMPServer (X:\Wamp, by default).
2) You should see a file "wampmanager.tpl" in this folder. Open it.
3) Search for "http://localhost/phpmyadmin/" and change it to "http://localhost:[YOURPORTNUM]/phpmyadmin/".
4) Save and close this file.
5) Restart WAMPServer.

That should fix it!

Cheers!
Karthick