Installing Apache 2.2 PHP 5.2 MySQL 5 on Windows 32bit or x64

This post is about getting MySQL working with Apache/PHP because sometimes it can be a pain to get it working.

If you are having trouble getting PHP working with Apache, one reader called Nurlan has found a guide to using the PHP MSI install wizard. You can find it at

Before You Begin

  • Read carefully
  • Keep backups of the files you change (make a copy before you change them)
  • Some long lines of text may run off the page on this website, so you need to copy the whole line down correctly

Downloading & Installing

Download the apache 2.2.8 installer (I used the one with SSL) and install it, I’ve installed to c:\apache2.2. You can run it from the start menu.

Download the PHP 5.2.6 zip and extract it (I used the no-msi zip). You don’t want space characters in the path, so I suggest C:\php5.2.6.

Download MySQL 5.01. I installed to C:\mysql5 because I didn’t use the installer. It will work just as well if you use the install wizard. Once installed, you can use the mysql monitor, which appears in the system tray (next to the clock) to start/stop the sql server.

Try  the MySQL GUI tools.  You can login using the mysql administrator, so you can setup usernames etc. You can edit schema (databases) and tables etc. using the Query Browser, it’s pretty straight forward to use.

Configuring Apache to use PHP

I like to make it obvious where I’ve made changes to files, so I can easily see them later. I do this by putting long comment lines above and below the changes.

Go into httpd.conf. find the bunch of LoadModule lines and add this one.

LoadModule php5_module C:/php5.2.6/php5apache2_2.dll

So In my file it looks like this

# Last changed on 28 July 2008.
# This line enables the PHP module
LoadModule php5_module C:/php5.2.6/php5apache2_2.dll

Add this line as well (i put it after the loadmodule line)

PHPIniDir C:/php5.2.6/

ZAUR left a useful comment on 29th June 2008. He mentions that it’s important not to have quotes around your path in this line. Thanks Zaur.

Find the bunch of AddType lines and add this one

AddType application/x-httpd-php .php

Configuring PHP to use MySQL

Go into C:\php5.2.6 and copy the file called php.ini-recommended, paste it into the same folder and rename it to php.ini. So you have a duplicate of php.ini-recommended called php.ini.

Find and edit the following lines;

doc_root = "C:\Apache2.2\www"
extension_dir = "C:\php5.2.6\ext"

uncomment this line (take the ‘;’ character out)



Now restart apache, everything should be working. You can check up on php by using the phpinfo() function. Just put the following line into a file called something like phpinfo.php and place it in your htdocs folder:

<?php phpinfo(); ?>

If php is running, it will give you a page with lots of information. Look for the mysql section, it comes after PHP Credits, Configuration, PHPCore etc. If it isn’t there, that means PHP is running but MySQL isn’t playing ball.

Check all the edits you’ve made the the config files, make sure they all make sense, sometimes you put the wrong slashes in, or the wrong folder name and it’s very hard to spot.

If you get the following error message:

unable to load C:\php5.2.6\ext\php_mysql.dll’

This is the most frustrating part of getting mysql working. PHP won’t run the mysql extension and you have to do stupid things to get it to work!

Copy C:\php5.2.6\libmysql.dll to c:\windows\system32\ and restart apache

IF YOU ARE USING WINDOWS XP x64 and moving the file to system32 doesn’t work, move it to C:\WINDOWS.



These guys have a suggestion. When copying libmysql, andy23 says:
Copy file libmysql.dll in C:\php5.2.6 to C:\apache2.2\bin\ AND C:\windows\system32

Hopefully, this will have got your servers up and running. Go ahead and try out wordpress, joomla, osCommerce etc.

If you find you can’t login to the mysql server, check my mysql posts with instructions on how to setup mysql user accounts.

Thanks to all the people contributing their time to open Source projects, and thanks to you for reading.


26 thoughts on “Installing Apache 2.2 PHP 5.2 MySQL 5 on Windows 32bit or x64”

  1. Man, you have saved my day… I spent 4 days trying to make my php work with mysql and nothing worked… you can find out a lot of webpages and forums with people having this same problem, but no solution is given. Your solution fit exactly for me, I’ll go to some foruns and link to your page ok? Once again, thanks a lot!


  2. Thanks for your comments!

    I know exactly how you feel, and i’m glad this post has been useful.

    Feel free to link or copy or whatever you want to do.

    I’ve installed apache+php+mysql a few times, but remembering how to fix all the problems is hard! So I made this page, for my own reference as well as everyone else.

  3. Hey cyleft…
    i followed ur every step… but at last when i tried to run info.php () all apache gave me was index page (directory index)..
    seems like php is not responding…. anyway i can fix this?…
    my apache path is “H:\Program Files (x86)\Apache Software Foundation\Apache2.2”
    my php path is “H:\php”
    my mysql path is “H:\Program Files (x86)\MySQL\MySQL Server 5.0”
    do you think this has anything to do with the paths having spaces?

  4. hi. just posting a quick reply to nurlan who, on 27 July 2008 GMT asked about php.ini-recommended. If you extracted php, you should be able to find a file called ‘php.ini-recommended’ in the same folder where you find ‘php.exe’. you can copy this file, and rename it to ‘php.ini’, so if you make a mistake, you can start again from ‘php.ini-recommended’.

    There is also another file in there that you can use called ‘php.ini-dist’. If you already have a file called php.ini, then you can edit that one instead.

    Thanks for the link to, that looks like a very useful tool, I’ll stick that link at the top of the post.

  5. Just want to thank you for taking the time to write such a clear, concise and effective blog on configuring a WAMP environment. I have read 15 other articles or so and could not get apache to recognise the mysql extensions. this is all working for me now in one go after uninstalling and following your instructions one by one. Thanks again. Claire

  6. Hi cyleft,

    Thank you for your detailed information. I have tried several ways and all were vain attempts. Fortunately i came across Ur article, which helped me to connect to MySQL.

    Though i see a mysql_error as Host ‘{ipaddress}’ is not allowed to connect to this MySQL server. I felt good that ur article helped me in connecting to mysql.

    Thanks Much

  7. Thanks for the effort, but none of this works. I am into my 3rd day trying to get this to work and may have no option but to use IIS.

    Any othetr suggestions than what has been posted here.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s