Bhaskar Karambelkar's Blog

Prototyping LAMP with WAMP

 

Tags: mysql windows apache lamp php wamp


WAMP is the windows equivalent of the LAMP stack. LAMP stands for Linux (Operating System), Apache (Web Server), Mysql (Database), and PHP (Scripting Language). Under WAMP, instead of using Linux as the Operating System, you use one of the Microsoft Windows OSes such as XP, 2000 or 2k3.

Why WAMP instead of LAMP

Windows OSes since 2000 i.e. 2k, XP , 2k3 have been extremely stable as opposed to their predecessors. So if you are proficient in Windows, then there is no reason not to use it for web hosting. (barring security, but that’s another issue). Secondly if you want to develop your site off line and then move it to a LAMP Stack, and you are not familiar with Linux, then WAMP serves as an ideal prototyping environment. You can do almost every thing in WAMP that you can do in LAMP.

Installing WAMP

WAMP is hosted at www.en.wampserver.com. Unlike LAMP where you have to install and configure each component seperately, wamp comes bundled in as one single installer, and installs every thing under one directory. WAMP also provides you with a System Tray Menu to start/stop configure various components. For someone new to web development this is a great feature to have.

To install WAMP, download and run the latest WAMP installer 1.6.3 from the site mentioned above. As of WAMP 1.6.3, it contains Apache 2.0.55 , PHP 5.1.4, MySQL 5.0.21 as the main components and also phpmyadmin 2.8.0.3 and sqllitemanager 1.2.0 as add-ons. By default the installer will place every thing under C:\wamp. The installer also creates 2 services viz. ‘wampapache’ and ‘wampmysql’ for starting/stopping Apache and MySQL respectively. The installer creates a handy ‘System tray monitor’ for managing WAMP.

Once installed, if you open a web browser on your windows box, and type http://localhost/ you should see, something like this. This confirms that you have successfully installed WAMP. You can click the phpinfo() link to see details of your PHP environment. Also you can use the pre installed applications phpmyadmin and sqllitemanager to configure MySQL and sqllite respectively.

Next up Configuring and managing WAMP

Configuring and managing

One neat thing about WAMP is Apache, PHP and MySQL can be configured from one single ‘System Tray App’. No need to go digging in explorer to find the relevent files. You can also start/stop apache and MySQL services using the ‘System Tray App’.

The default configuration is sufficient to get started, but we are going to perform certain customizations.

  • ### Create a password for MySQL root account.

First things first, the default WAMP install, creates a MySQL super-user (root) account with no password. This is OK for prototyping, but if you have an internet facing m/c, you should create a password for that a/c. This is easily done using the pre installed phpmyadmin web application.

Open the URL http://localhost/phpmyadmin/ in a web browser. This should bring up the phpmyadmin page. This is the starting point of controlling everything related to MySQL.

Click on the ‘Privileges’ link, that should bring up the user accounts page. Click on the icon besides the ‘Grant’ column, to edit root user’s properties.

On the following page, scroll down to ‘Change password’. Select the ‘Password’ check box and supply a password. Click ‘GO’ button when done. This should setup a password for the root a/c. But we are only half done, now that the root a/c has a password, phpmyadmin application will not work unless you edit a config file and put the password in there. To get phpmyadmin working again , open the file ‘C:\wamp\phpmyadmin\config.inc.php’ using wordpad (any text editor). Change the line

$cfg['Servers'][$i]['password'] = ''; to $cfg['Servers'][$i]['password'] = 'newly-created-password';

This will make phpmyadmin work correctly again.

Next up Configure Apache

  • ### Configure Apache

Configuration files for Apache, PHP and MySQL can be easily accessed using the system tray icon, as shown by the figure in left. Click on ‘http.conf’ to access apache’s configuration file. We are not going to change much here. Scroll down till you see a bunch of ‘LoadModule xyz’ statements. Some of the Apache modules are commented out. Uncomment the following 3 modules by removing the leading ‘#’ 1) mod_status , 2) mod_info and 3) mod_rewrite. mod_info and mod_status provide us with vital statistics regarding the apache server, (these shouldn’t be enabled on a production server). To be able to access the server info and status , we need to uncomment a few more lines. First of change the line ExtendedStatus Off to ExtendedStatus On, next search for and uncomment lines between

<Location /server-status>...</Location>

and

<Location /server-info>...</Location>

This will enable us to get the server status and info by navigating to URLs http://localhost/server-status and http://localhost/server-info respectively. If you install a PHP Content Management System (CMS) such as Drupal then it can use mod_rewrite module to output search engine friendly URLs. * ### Configure PHP and MySQL

In case you need to configure PHP (add/remove extensions), you can use the ‘System Tray Monitor’ or directly edit C:\wamp\apache\bin\php.ini file. Similary to configure MySQL edit C:\wamp\mysql\my.ini

Final thoughts

Installing and configuring WAMP is really easy and straight forward. It is an ideal prototyping platform for any one who wishes to develop for the LAMP stack. And if you are feeling adventurous you can use WAMP as your final platform as well. I have also installed Drupal and Gallery on top of WAMP without problems.