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. Have done everything you suggest. Still will not work with Windows 7! When I try to open Test.php, Firefox asks me where i want to open Test.php and suggests Notepad.

    this is very frustrating. “One reason is because as because on my older computer running XP and all is well.Everything works fine. Can I send you any file to see if you can see what I am missing?

    Thank you for all the work you have done!

  2. It doesnt work. i have windows 7 and do process all as u write. but after rebooting apache server can’t start & gives error “The requested operation has failed”

    1. I just checked using PHP 5.4.10 with Apache 2.4.3 on Windows 7 (which is the latest version at the time i write this) and PHP can detect and load the custom php.ini correctly using the PHPRC method and not using PHPIniDir directive in httpd.conf at all. As displayed at php info page as Loaded Configuration File

  3. Thanks a lot man, i spent my whole night trying to get this to work. almost every tutorial about that is wrong. Once more, thank u very much.

  4. thanx for all, i have gone thru all the procedures discribe in the guide but failed on the last step. am using windows7 but after all the steps when i browser i dont get the page displayed.but msg that the server cant be located. may some other thing was that i failed to locate the modules as directed and tha overide all step.

    1. Hello Francis,

      First of all i’m so sorry for late response, and to answer your question, are you sure that Apache is running? if Apache isn’t running you can diagnose the problem yourself by taking a look at its error log or you could post what’s in the log file to so i can take a look at it (the file name is error.log located in your Apache directory)

  5. and great guide by the way, much more in depth configuration of apache and php than other guides (sorry for the double post!)

  6. Just wanted to comment for those who may be having the same problem – make sure (yes, even with 5.4) that you download the THREAD SAFE version, or you will not have php5apache2_2.dll fill in ur php directory…. its an easy mistake to make….

    good luck!

  7. This does not work at all for Windows 7. After starting Apache Web Server and entering: http://localhost into the address bar of IE (or any browser), I get a HUGE error.log in logs: “An operation was attempted on something that is not a socket. : Child 9144: Encountered too many error accepting client connections. Possible causes: dynamic address renewal, or incompatible VPN or firewall software. Try using the Win32DisableAcceptEx directive.” This makes no sense, since I am running none of that. Also, the error log balloons up to 700 MB if not stopped quickly.

    1. Actually this has been tested on Windows 7 and it works just fine. Personally i never experienced such error and i’ve been using Apache since version 1.x so i had to look it up and your problem probably related to this bug. In fact i just tested running Apache 2.4.2 on Windows 7 then goes to open the localhost page just now but i didn’t experience your problem here

      According to a quick search fhe fix is by adding Win32DisableAcceptEx into httpd.conf as described at

      Note: according to the url linked above

      Some popular Windows products, typically virus scanning or virtual private network packages, have bugs that interfere with the proper operation of AcceptEx()

      I’m guessing there’s an antivirus/vpn software on your system interfering with Windows operation that causes this problem. In my opinion it’d be best to fix the offending software first

    1. Could you post apache error.log (located in your apache directory under logs subdirectory)? also are you trying to use PHP higher than 5.3.5?

      p.s use to paste your log :)

    2. My problem is that i think i cant install apache. since theres no install program in the zip? how do i donthis

    3. It seems that you’re not using the Apache binaries by, then please see the update to install it :)