How to Install Apache, PHP and MySQL on Windows Vista / Windows 7

This is a guide about Installing Apache, PHP, and MySQL on Windows Vista or Windows 7. Although setting up Apache, PHP and MySQL on Windows Vista / 7 is pretty much the same like setting up Apache, PHP and MySQL on Windows XP, it seems some people are having problem with it, although the only difference between those two is just there is User Account Control (UAC) in Windows Vista that basically prevent you from writing / editing files inside Program Files directory if you aren’t opening that files with Admin priviledge even if your account is in Administrator group. And this guide tells you how to configure Apache, PHP, and MySQL even when you installed it to Program Files directory without disabling UAC

Before we begin … this guide is compatible and has been tested with Windows 7 although the screenshots used here is showing the installation process under Windows Vista but that’s because back when i write this i’m still using Vista

Also it doesn’t matter whether you have x86 or x64 version of Vista / 7 installed. The only difference in this case is, if you’re running the x64 version, the Program Files directory for 32-bit program is called Program Files (x86)

And here goes the guide…


Apache HTTP ServerDownload Apache – Please see Update right below this before downloading this

PHP for WindowsDownload PHP – Please see Update right below this before downloading this

Make sure to download the Thread Safe version because we’re going to load PHP as Apache module

MySQLDownload MySQL

If you prefer a smaller version you can choose to download the Essential version to save your time and bandwidth which is really useful if you have slow connection speed like me

At the time i wrote this the latest version of Apache is 2.2.15, PHP 5.3.2, and MySQL 5.1.45


Because PHP no longer provide the PHP VC6 binary since version 5.3.6 directly on their website, there are two options for you to choose from:

1. Stick with PHP 5.3.5 VC6 and Apache binaries from official Apache website (the last version of PHP that is compiled using VC6) and can be downloaded from here

2. Use the VC9 version of PHP 5.3.6 and higher and also use Apache VC9 binaries built by

If you’re going with option 1 then you can just simply follow the guide above, but if you choose option 2, the easiest way to install it is:

1. Download Apache binary from and then download VC9 PHP from PHP website

2. Extract the apache into C:\ (so the apache directory ended up in C:\Apache2)

3. Open httpd.conf in C:\Apache2\conf and:

# Search for DocumentRoot "c:/Apache2/htdocs" and replace it with
DocumentRoot "c:/htdocs"

# Right above the DocumentRoot add ServerName

# Then search for Directory "c:/Apache2/htdocs" and replace it with
Directory "c:/htdocs"

4. Now run command prompt as administrator and then type:

cd /d C:\Apache2\bin
httpd -k install

5. As for the rest (PHP and MySQL setup) you can follow the guide below :)

Installing Apache on Windows Vista / Windows 7

1. First of all run the apache installer until you reached this Apache server information screen and fill in localhost (or other value you want but to make it simple i just put localhost)

Apache Server Information

2. Then choose Typical for the setup type

Apache Typical Setup

3. And then when asked to choose the installation directory, make sure to use the default path to install it to program files directory as shown below (because that’s what this guide all about, to assist you to install apache into program files directory while UAC enabled)

Apache Install to Program Files with UAC Enabled

4. After installing Apache you will see there’s a new icon installed on the System Tray (where the clock displayed in Windows), the new icon is called Apache Service Monitor, which is basically a tool to help you to Start/Stop/Restart Apache quickly and when you double click on it you’ll see this

Apache Service Monitor

Configuring PHP with Apache on Windows Vista / Windows 7

1. Create a new directory named PHP5 in C:\ so it’ll end up like below image for an example (you’re free to use other path, but if you choose to put it in different path, make sure to adjust them accordingly because in this guide i assume the PHP is extracted to C:\PHP5)

PHP Extracted to C:\PHP5

2. Find php.ini-production in C:\PHP5 and then rename it to php.ini

Rename php.ini-production to php.ini

3. Now you need to open php.ini using your favorite text editor (in this example i use notepad) and locate extension_dir directives and change the value into


php extension_dir

4. Now you need to find output_buffering and change it to

output_buffering = Off

output buffering off

5. Find php_bz2.dll, php_mbstring.dll, php_mysql.dll, and php_mysqli.dll at the extensions section in php.ini and uncomment it (by removing the ; character)

Enabling php_bz2, php_mbstring, php_mysql and php_mysqli

6. Now we’ve finished configuring the php.ini, and so for the next step we’re going to run notepad as admin

Running notepad as admin

7. Now while running notepad as admin, you need to open C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf or C:\Apache2\conf\httpd.conf

Open httpd.conf as admin

8. After opening httpd.conf, locate and uncomment expires_module, headers_module, rewrite_module so you won’t have to enable them later because those three are perhaps the most commonly used apache modules especially the rewrite module and obviously you’re free to enable other modules you deemed necessary and when your done then add

LoadModule php5_module "c:/php5/php5apache2_2.dll"

Uncomment mod_expires, mod_headers, mod_rewrite, and add php5_module

9. Now you need to find this in httpd.conf

<IfModule dir_module>
DirectoryIndex index.html

and replace with

<IfModule dir_module>
DirectoryIndex index.html index.htm index.php

add directoryindex in apache

10. As for the next step, you need to locate (still in httpd.conf)

<IfModule mime_module>

and inside that directives, add:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

php addtype to httpd.conf

11. Because Vista/7 UAC doesn’t allow you to create / edit files in Program Files directory, then the next step would be changing the root directory of your server from C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\ (default) into C:\htdocs. And to do this you’ll need to find:

DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"

and replace it with

DocumentRoot "C:/htdocs"

then find

<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs">

and replace it with

<Directory "C:/htdocs">

then find (inside the Directory directives)

AllowOverride None

and replace it with

AllowOverride All

Replacing htdocs, directory and allowoverride

12. Now you need to open System Properties and you can do this by pressing Windows Key + Pause/Break or by right clicking on My Computer then choose Properties, and then followed by clicking Advanced System Settings

Windows Vista System Information

13. At the System Properties, go to the Advanced Tab and then click on Environment Variables

Windows Vista Environtment Variables

14. Now you need to add PHPRC into System Variables, and to do this you just need to click on New at the System Variables section and then add

Variable name: PHPRC
Variable value: C:\PHP5


15. Still in Environment Variables, next you need to double click on Path under System Variables and then add


Add PHP path

16. Now we’re done with the Environment Variables. The next step would be creating a directory named htdocs in C:\ (C:\htdocs) and then create a file named test.php inside that directory

create htdocs in c and then create test.php inside it

17. Open the test.php file you just created with notepad and add this line

<?php phpinfo(); ?>

18. Now we’re done with the PHP + Apache integration. Save your work and then restart your computer

19. Finally after finished with the booting process, now open your favorite browser (in this example i use Internet Explorer 7 which is the default browser for a freshly installed Windows Vista or if you’re running Windows 7 the default is IE8) and then type


Apache PHP Windows Vista done

And you’re done with Apache PHP integration process :) … now we’re going to continue with MySQL installation on Windows Vista / Windows 7

Installing MySQL on Windows Vista / Windows 7

1. For the first step you would need to run the MySQL Installer, then choose Typical setup type when asked to install it to default directory

installing mysql on vista

2. Continue with the installation process

mysql installation on vista

3. When you reached this screen after MySQL installation process finished, check Configure the MySQL Server Now and uncheck Register the MySQL Server now (but it’s up to you whether you want to register or not)

configuring mysql

4. When asked for the configuration type, choose Detailed (because you want better control obviously) ;)

detail mysql config on vista

5. Then choose Developer Machine as the server type to make sure MySQL doesn’t eat too much memory (well if you have plenty of RAM then feel free to choose other server type to suit your needs)

mysql server type

6. And then choose MultiFunctional Database when asked

mysql database type

7. When asked for the InnoDB storage location, choose C:\MySQL InnoDB Datafiles\ (but of course feel free to use different path if you want)

innodb path

8. And when asked for the max concurrent connection that MySQL would accept choose Decission Support (DSS)/OLAP (but if you think that you’re going to have many concurrent connection later especially if you’re running a popular WoW Private server then you can choose Manual Setting and choose the best value for your application, but make sure to not put a very high value)

max concurrent connection

9. When you reached the MySQL networking options, just leave it at default value

mysql networking options

10. As for the MySQL default character set, choose Best Support for Multilingualism to make UTF8 as the default charset

mysql default charset

11. And then when you reached Windows options, don’t forget to check Include Bin Directory in Windows PATH so you can access MySQL easily from the command line from anywhere

12. Now comes the most important part of the MySQL installation, and that is setting a root password for MySQL (root is the superuser in MySQL, make sure to remember root password and don’t give it to anyone else)

mysql root password

13. Now you’re done installing MySQL

mysql vista done

And you’re done installing Apache 2.2, PHP 5.3 and MySQL 5.1 on your Windows Vista / Windows 7 computer. Hopefully you enjoy this quick guide and of course if i missed / forgot something, please do let me know in the comment area below :)

Note: Updated because this guide can also be used on Windows 7, and also because from PHP 5.3.6 onward, they only release VC9 version which is not compatible with Apache binary from official Apache website


Note: Comment may not appear right away.

139 comments on “How to Install Apache, PHP and MySQL on Windows Vista / Windows 7

  1. I can’t seem to get past the last step for php. When I go to http://localhost/test.php all I get is a “can not display this page” in IE and Firefox, and a “can not connect to localhost” in Chrome. What am I doing wrong?

  2. Hey, I’m having the same crash location as Nick the Greek…

    The installer seems to stop responding as soon as it checkmarks “write configuration file (C:Program FilesMySQLMySQL Server 5.1my.ini)”

    As it crashed like this in the original config, I’ve since run the config from the start menu with the same results.

    Any help would be great.

    1. Sorry, uninstalled and reinstalled it… It no longer crashes at that point. I think it may have been an issue with the installation directory.

  3. Thank you. This is the most comprehensive & updated tutorial for configuring Apache & PHP. Great work.

  4. also when i reach the final step of mysql installation and when it reaches the write configuration file part the program crushes

  5. hi reaper x your guide is perfect and nice work:) eeh i got a problem which i dont i kn ow if it is a problem exactly. i’ve done everything installing php but when i open internet explorer(i have windows7) and copy paste “http://localhost/test.php” its drops a window which says open or download and it doesnt load the php page what should i do? thanks

  6. hey Reaper-X, first of all really nice website/guide, you put everything together pretty well. However, I am having an issue when it comes to the last few steps of creating the test.php… it keeps it as a text document and I don’t know how to change it. Putting it on the end is not proving useful. Also when i try to login to the server it tells me that it is unable to connect to it. If you could please assist me with these issues that would be excellent. Thanks :)

  7. Hi Reaper-x, just a follow up. i got the error below when I ran my test to check if my PHP + Apache installation is correct. [Wed May 19 19:13:57 2010] [error] [client] script ‘C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/phpinfo.php’ not found or unable to stat
    Thanks in advance. DTG

    1. Does the phpinfo.php file exist in that directory? make sure that the filename is phpinfo.php not phpinfo.php.txt (many people seems to add the .txt extension which result in 404 not found error)

  8. Hi Reaper-X, Thanks for helping fix installation/configuration issues. I have the same problem re; error 404. Could you please help where to specify the DocumentRoot “c:/htdocs”. Thanks. DTG

  9. Got a problem with the Mysql install tho, the program stops answering at the installation (on ur last picture if u get me). The two last dots (Start service and Apply security settings) wont get checked and program stops working. Any ideas?

    1. Stop responding? try running mysql server instance config wizard again from the start menu :)

    2. Jea, done like 100times now :p The install ‘mysql server instance config wizard’ still wont respond. But when I do make a second attempt to install it it asks for the ‘previous password’ when I’m asked to type a password. Is there any other versions I could try or got some other idea? Thnx reply! :D

    3. Tryed to run it as administrator as in windows xp comp mode, dident work : AID ME PLX!! :P

    4. Im on the “Installing mangos database” part on your wow server guide you see and i get this error after i have typed
      ‘mysql -uroot -p -v < create_mysql.sql':
      'Error 2003 (HY00): Cannot connect to MySQL server on 'localhost' (10061)'
      Im just guessing I get that error since I cannot complete the MySQL instalation, allthought it might be something else!?

      It would be nice if you could just add me on msn: [email protected]! :)

    5. Can’t connect to mysql server? are you sure that mysql is running? try typing this command at the command prompt

      netstat -anb

      And see whether mysqld is listed there (Listening at port 3306 by default unless you changed the port) ;)

      And of course i can add you on messenger but problem is i live in different timezone (look at the comment time in case you didn’t notice, that’s is my local time) :D

    6. Well I’ll be damnd! It’s not there! Hope that’s good news! How do I get mysql running then? I’ve really got zero clue on these stuff! :)

    7. First of all sorry for late reply because i didn’t notice there was a new comment here

      And to answer your question, well first you need to install mysql (as described in this guide) or if you have installed mysql and hangs during the configuration process, try running the mysql server instance config wizard again from the start menu

      If all goes well mysql will be started automatically :)

    8. jea u know that’s the thing, even tho i start it from the startmenu it wont work, so im guess that’s why mysql wont start either! :

    9. Try opening windows run (windows key + r) and then type services.msc, and see whether mysql service is listed there, if you can see mysql entry try starting from there :)

    10. jea its there! So im guessing thats good, but when i try to start it I get a error 1067 – Process finished of unexpected.

    11. Can you paste the content of my.ini here? (it’s located in your mysql installation directory) :)

  10. Hi! First i just have to say awesome guide!

    And here is my problem:
    When I’m trying to accsess the test web-page (http://localhost/test.php) my browser wants to download the test.php file! Before this problem I had a 404 error which i managed to fix somehow in the Environment Variables i do belive.. Any ideas on why it wants to download and not display the file?

    1. Nvm man fixed it :D I had forgot to add

      LoadModule php5_module “c:/php5/php5apache2_2.dll”

    2. Getting “Unable to connect. Firefox cannot establish connection to localhost”. IE says about same worded message. Done everything guide says and still cannot connect. need some help plz.

  11. at the Prerequisite
    PHP for Windows – Download PHP
    Make sure to download PHP 5.3 VS6 Thread Safe version
    there is no PHP 5.3 VS6 Thread Safe version
    there is only PHP 5.3 VC6 Thread Safe version
    is this a problem???

    1. Ah no actually VS6 = Visual Studio 6, and VC6 = Visual C6 which is basically the same because Visual Studio includes Visual C in their distribution :)

      But anyway i think it’d better if i changed it into VC6 to avoid confusion, thank you very much for your attention :)

    2. Try disable php first (by removing LoadModule php5_module “c:/php5/php5apache2_2.dll”)

      and see whether apache works or not without php

  12. Ok, now i got what was the the issue. I can’t just create a textfile and slap .php behind it, it still is a .txt file :P

    So i made a .php file, but this time when i run the test the only thing that appears is:

    I went over your guide three times now, and i have no idea on how to get the server to appear like the last screenshot shows.

    Help is greatly appreciated!

    1. this shows up is what i meant to say:

      AND, i checked the logs. I get this error message:

      [Sat May 08 19:42:41 2010] [error] [client] File does not exist: C:/htdocs/favicon.ico

    2. Ah yes if phpinfo doesn’t show your php information that means you forget to add these lines

      AddType application/x-httpd-php .php
      AddType application/x-httpd-php-source .phps

      And oh btw, i’m sorry if my filtering system has caused you problem :)

    3. well, this is embarrasing. I just forgot to add a “s” at .phps… so it was just .php…

      Thanks you for you help anyways, and keep making these guides, they kick ass.

  13. I don’t get it. I have done everything Apache and PHP guides have told me except install apache in Program Files, yet I still get the 404 Error. I don’t get it, what am I doing wrong?

    1. If you get 404 error that means that file that you’re looking for can’t be found :)

      I’d suggest you to check your apache log file, and also make sure that that file is exist (for example if you’re going to check test.php file make sure that it is exist within the document root)

      For example if you set

      DocumentRoot "c:/htdocs"

      That means you need to place your file there

  14. I followed your guide to the letter but i can’t get apache 2.2 to run.
    It keeps saying that OCI.dll is missing from my computer

    1. Also this is from the error logs:

      “[warn] pid file C:/Program Files (x86)/Apache Software Foundation/Apache2.2/logs/ overwritten — Unclean shutdown of previous Apache run?”

    2. Did you enable php_oci8 extension? if you enabled it, i assume that you want to use php with Oracle Database, and so you’ll need to check your Oracle installation first and see whether oci.dll is included or not (because in this guide i didn’t mention about Oracle anywhere) :)

      And if you think you made mistake like for example, you want to enable php_mysqli.dll but choose to enable php_oci8.dll then you can just simply add ; before php_oci8.dll to comment / disable php oci extension and uncomment / enable php_mysqli.dll instead :)

      p.s php_oci8.dll is located right below php_mysqli.dll (see step #5 image in php integration). So i’m thinking that you made a mistake by enabling php_oci8.dll instead of php_mysqli.dll

    3. Indeed, I enabled php_oci8.dll instead of php_mysqli.dll, my bad.

      Everything works just fine now.

    1. Colored code? could you upload a screenshot somewhere because i’m confused whether you’re talking about php file not being parsed or something else :)

      but if php file not being parsed, check that you have this line on your httpd.conf (step #10 at installing php)

      AddType application/x-httpd-php .php
      AddType application/x-httpd-php-source .phps

  15. Hey Reaper I seem to be having similar issues with The PHP/Apache integration as well…. Made the test file, and when I finally try to pull it up on the browser, I get HTTP 403 Error code, also stating I need to log in… This is my third attempt at this, and I could really use the help.

    1. Get Login message? perhaps you’re trying to connect to other process that is running at port 80

      Try running this command at the command prompt

      netstat -p TCP -a -b

      and see if you get output that look like this (this is to check whether you’re connecting to apache http server on your computer or other process that also run on port 80 like Skype for example)

      TCP xxxxx:http xxxxx:0 LISTENING XXXX [httpd.exe]

  16. I do everything you say to do but I cant seem to get it to run right.

    I do the local host test and the search doesnt give me any results.

    1. Could you tell me what the exact problem is? is it php not being parsed? because i don’t understand what do you mean by search doesn’t give me any results

      Are you looking for the test.php file? because if that’s what you mean, you need to create the test.php file by yourself :)

    2. Alright, im gonna start from the beginning again. Ive uninstalled and removed everything. Ill let you know if I have any more issues.

    3. In my PHP5 directory, the c:/php5/php5apache2_2.dll file is there.
      But it keeps telling me that the specific module cannot be found.

    4. It is telling me.

      [Mon May 03 04:44:09 2010] [error] [client] script ‘C:/htdocs/test.php’ not found or unable to stat
      [Mon May 03 04:44:09 2010] [error] [client] File does not exist: C:/htdocs/favicon.ico

  17. Nice to see all the new articles! Back up and running. You found some good topics. No help from me lols!

    1. Hahaha well they just came to my mind (not actually came to my mind tho, because it’s a request from someone) :D

  18. This is interesting. Setting up a web server on vista. Pretty rare topic to find though so this should bring attention to the site for any people looking to host from home!

    Keep up the writing man, I always like reading it!

  19. Hey Reaper I got a pretty cool article for your site ill type it up for you so you can post it! Its really popular but its hard to find the updated hack version for non techy people lol. Just let me know which email to send it to.