Installing WAMP - Apache, MySQL, & PHP on Windows 7

Installing WAMP on XP was pretty easy; W7 is not so trivial. It's not difficult once you know, but it took me best part of a day to figure out and required gleaning various bits of information from around the web; this tutorial brings it all together in one place to (hopefully) make other peoples lives that bit easier. It does assume that you are reasonably happy configuring Apache, PHP, and MySQL and mainly deals with the W7 quirks.

All installations must be done with administrator privileges.

>Info: A far easier way of setting up a server environment is to use pre-configured server packages, such as XAMPP. Please take a look at this Yii Cookbook article for more information.

Apache

The details are for Apache 2.2. At the time of writing the Windows Apache installation (2.2.15) is not Windows 7 savvy; however, a couple of tweeks makes it fit right in.

Download and install Apache allowing it to make changes to your computer as and when W7 asks.

When asked by the installer for the "Server Information" enter localhost in both the "Network Domain" and "Server Name" fields, and a suitable e-mail in the "Administrator's Email Address"; unless you have good reason not to, accept the default "for All Users, on Port 80, as a Service". Click "Next".

When asked, accept the default installation directory which will be C:\Program Files (x86)\Apache Software Foundation\Apache2.2.

Edit your hosts file; this is in C:\Windows\System32\drivers\etc. Uncomment the lines (delete the # character):

127.0.0.1       localhost
::1             localhost

Once the installation is complete you should have the Apache Monitor icon in the Notification Area (you will probably need to click the up arrow to see it). Hopefully this will have a green "play" icon in it to show the server service is running. If not double click it then press "Start".

To make sure everything is OK start your web browser and enter http://localhost/ in the address bar; you should see a page with the words It Works!.

Making Apache fit into W7

Great, it's all working so the next thing is to configure it. Trouble is W7 won't let you save the configuration files back to the directory that they are in; the same is true for the htdocs directory, meaning you can not conveniently add sites. Hopefully the Apache team will change this to support installations on W7, but until they do ...

Create New Folders for the Configuration and Website Files

These can go almost anywhere; under you user directory, in documents, desktop, etc.; they don't even have to be in the same place. They can also go in a folder called ProgramData; this is a hidden folder but is where W7 savvy programs put their configuration data. I'll be using this; just change the path(s) if you put them elsewhere.

Under the ProgramData folder create a new folder called Apache Software Foundation, under that create a folder called Apache2.2.

Using the Apache Monitor stop the server service.

In a separate explorer window navigate to C:\Program Files (x86)\Apache Software Foundation\Apache2.2 and copy and paste (NOT drag and drop) the conf and htdocs folders to their new home. Now delete the original conf and htdocs folders confirming that you want to do this when W7 asks.

We now create symbolic links to the new locations of the conf and htdocs folders. Open a command prompt from Start Menu->Accessories - do NOT start it by clicking on Accessories, but do so by right clicking and select "Run as Administrator" saying Yes when W7 asks if this it's allowed to make changes. In the the command prompt type (<CR> = the enter key):

cd "C:\Program Files (x86)\Apache Software Foundation\Apache2.2"&lt;CR&gt;

This takes you the Apache installation directory. Now type:

mklink /d conf "C:\ProgramData\Apache Software Foundation\Apache2.2\conf"&lt;CR&gt;

and:

mklink /d htdocs "C:\ProgramData\Apache Software Foundation\Apache2.2\htdocs"&lt;CR&gt;

Restart the service from the Apache Monitor. If the service does not start chances are you made a typo in the conf symbolic link.

Delete it by typing rd conf and re-make it. Now type http://localhost/ in the address bar of your browser and confirm you get the It Works! page. If the page does not appear chances are you made a typo in the htdocs symbolic link. Delete it by typing rd htdocs and re-make it.

Once all is working you can configure Apache as normal by editing the configuration files in their new location and add web pages under the new htdocs directory; don't forget to restart the service if you change the configuration.

PHP

Download and install PHP as normal.

If your PHP installation is under C:\Program Files or C:\Program Files (x86) you will not be able to edit php.ini where it is for the same reasons we discussed earlier; the solution is pretty much the same too.

Under C:/ProgramData (or somewhere under your user account, just change the paths here accordingly) create a folder called PHP. From another explorer window copy and paste your php.ini file to the new folder and delete the original.

If it's not still open, get a command prompt (make sure to start it as outlined above) and type:

cd "C:\Path\To\PHP"&lt;CR&gt;

where C:\Path\To\PHP is the path to your PHP installation. Now type:

mklink php.ini "C:\ProgramData\PHP\php.ini"&lt;CR&gt;

In your Apache httpd.conf file add the following (or add an include to a file with the following) lines (replace C:/Path/To/PHP with the path to your PHP installation):

# PHP5 Apache 2.2 module
LoadModule php5_module "C:/Path/To/PHP/php5apache2_2.dll"
AddHandler application/x-httpd-php .php
# Path to php.ini
PHPIniDIR "C:/Path/To/PHP"

MySQL

Download and install MySQL allowing it to make changes to your computer as and when W7 asks.

Edit your php.ini to load the required extension(s); for Yii you will need the PDO and PDO_MySQL extensions.

You now need to add the PHP directory to your Windows PATH Environment Variable so that W7 can find the libmysql.dll file. Do this by right clicking "Computer" in the Start menu or on your desktop and select "Properties". From the window that opens click "Advanced system settings" on the left; this opens a window called System Properties. Select the "Advanced" tab then click the "Environment Variables" button towards the bottom. In the "Environment Variables" window that's opened you want the lower set - "System variables".

Select "Path" (scroll to find it if necessary) then click the "Edit..." button and add the path to your PHP installation at the end preceded by a semi-colon. Click OK three times.

Job Done

Finally , restart your Apache server using the Apache Monitor to load the modified php.ini and you're good to go.

A good way to make sure all is working as required is to run Yii's requirements script, this will tell you what is and isn't installed as far as Yii is concerned; phpinfo() is of course another good way to see what's enabled in your system.

2 0
1 follower
Viewed: 46 168 times
Version: 1.1
Category: Tutorials
Tags:
Written by: Yeti
Last updated by: Trejder
Created on: Jun 29, 2010
Last updated: 14 years ago
Update Article

Revisions

View all history