How to Install Apache 2.4 MySQL and PHP on Windows Server 2012 R2

Well it is finally time to start playing a bit more with Microsoft’s latest server OS Windows Server 2012 R2. One of the many things to have on the list is getting the WAMP (Windows/Apache/MySQL/PHP) stack working. So in this post we will get installed and running Apache 2.4.9, MySQL 5.6.19 and PHP 5.5.13 on Windows Server 2012 R2. Also, instead of 32 bit apps we will be install 64 bit.

You will need to download and install  Visual C++ Re-distributable for Visual Studio 2012 from You will also need .NET 4.0 installed as a prereq for MySQL and Visual C++ 2010 re-distributable

Download 64 bit Apache ( from Download and extract the zip and copy it to the root of C:\. This will be C:\Apache24 when it is all done.

Download Thread Safe from . Extract and rename folder to php and move to C:\.

Extract  Edit Apache’s config file, c:\Apache24\conf\httpd.conf and add the following lines to the bottom of the file.

LoadModule php5_module "c:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php"

While we are at it we can add index.php to Apache’s list just incase we want to have a starting page as php.

Find Directory index and add index.php

DirectoryIndex index.html index.php

Next we need to input a value  for ServerName variable. You will have to un-comment it. Save the changes to the config file. Next move to the Register Apache Service step.

Register Apache Service

Now let’s register Apache as a service. Open a command prompt and type.

c:\apache24\bin\httpd -k install

If do not want Apache starting automatically at start-up/reboot:


  • Type in services.msc, hit Enter or click OK
  • Locate Apache2 service and double-click (or right-click for Properties)
  • Find the caption Startup type: (in the middle of the dialog box), use the pull-down and select Manual
  • Click OK

Command line

C:\> sc config Apache2.4 start= demand


;c:\php;c:\Apache24; c:\Apache24\bin;

to PATH in Environment variables. PATH ENVIRONMENT (System Properties | Advanced | Environment Variables | System variables | Path).

Now lets check Apache settings by issuing the command, c:\Apache24\bin\httpd -S

PHP Edits

Now we have to do a few edits to the php.ini file to tell it to load support for mysql and the location for the extensions. Since there is not a already set php.ini file we need to rename one of the two examples to php.ini.

Rename c:\php\php.ini-development to php.ini

Now let’s edit php.ini
Uncomment extension directory.

; Directory in which the loadable extensions (modules) reside.
; extension_dir = "./"
; On windows:
extension_dir = "ext"

Uncomment mysql modules

Save the changes and open a command prompt. Restart Apache to re-read the changes made to PHP.

Check to make sure it shows loaded modules.

C:\> c:\php\php -m

So now we have Apache running and configured to use php. Lets create a file called info.php, save it and see if Apache parses the info correctly to display the results.

Open Notepad or your favorite Windows editor and type and save the following.


Open your browser and type, localhost/info.php for the location and you should receive alot of information about PHP.

Download and install mysql-5.6.19-win64.msi. Change installation directory to C:\MySQL\MySQL Server 5.6 instead of Program files as there could be permissions issues. Once the installation is completed you can let the configuration wizard run and setup the database server. The defaults will work just fine, but remember what you set the password to for root.

PHPMyAdmin is a very nice tool to use for administering your MySQL installation.
Download and install
Extract the file and move to c:\apache24\htdocs. Rename directory to phpmyadmin.
Create a config directory under phpmyadmin. Open a browser and type localhost/phpmyadmin/setup/index.php to complete the installation.

At this point you should have a working Apache / PHP / MySQL installation running and ready for you to start developing !!!



58 Responses to “How to Install Apache 2.4 MySQL and PHP on Windows Server 2012 R2”

  1. Chuck says:

    Thank you so much for this! This saved me a ton of time and worked perfectly!

  2. Eugen says:

    Hi, thanks for this very helpful information here. I am in the process installing all from scratch. Also, tons of files bringing from Win 2003 server, but I only hope all will go ok someday,,

  3. priya says:

    Hello, Its really very nice blog but i am stuck here so plzz give me solution. myphp and apache are working fine but i installed mysql in c/program file so now i get this error

    “Your PHP installation appears to be missing the MySQL extension which is required by WordPress.”

    • newlife007 says:

      Change installation directory to C:\MySQL\MySQL Server 5.6 instead of Program files as there could be permissions issues. Once the installation is completed you can let the configuration wizard run and setup the database server. The defaults will work just fine, but remember what you set the password to for root. Also on the PHP Edits sections you need to:
      Uncomment mysql modules
      in c:\php\php.ini

      You probably need to uninstall and reinstall mySQL as being installed in c:\program Files causes issues.

  4. Sergey Romanov says:

    Hello, I’ve faced with the issue that extensions of PHP dont work.
    I had “Fatal error: Call to undefined function mb_detect_encoding()” when I was openning “localhost/phpmyadmin/setup/index.php”
    I’ve seen than phpinfo() have no enabled extensions.
    So, I’ve solved it.
    Just change in php.ini
    from “extension_dir = “ext””
    to “extension_dir = “C:/php/ext””

    • newlife007 says:

      Actually you didn’t have to add the full path, there are two steps in the post that show adding c:\php to the Windows Path environment variable and also the edits to the httpd.conf file. The Path change will not be noticed by the OS until you reboot. By making those changes it should be able to see ext.

  5. Peter says:


    I followed the setup and everything is working except the phpmyadmin module. I originally got a similar error to above, but that seems to have disappears now I just get a loading screen and then an error when the page doesn’t load.

    Also – where exactly is this step:

    ;c:\php;c:\Apache24; c:\Apache24\bin;

    to PATH in Environment variables. PATH ENVIRONMENT (System Properties | Advanced | Environment Variables | System variables | Path).

    • Peter says:

      OK. I added the path – Do I add a new one or to the existing ones that are there (temp and tmp). Unfortunately I still get just a blank screen.

  6. srianto says:


    Thanks for the post.

    I get following error:


    Deprecated: Non-static method PMA_Theme::load() should not be called statically, assuming $this from incompatible context in C:\Apache24\htdocs\phpmyadmin\libraries\Theme_Manager.class.php on line 259


    [17-Oct-2014 03:56:47 UTC] PHP Warning: PHP Startup: Unable to load dynamic library ‘C:\PHP\ext\php_oci8_12c.dll’ – %1 is not a valid Win32 application.


  7. srianto says:

    One more OCI error:

    Fatal error: Call to undefined function OCIPLogOn() in

  8. rama says:

    Dear newlife007,
    Thanks so much for this posting.
    I am in the process of migrating our server from Windows Web Server 2008 R2 to Windows Server 2012 and need this information.
    We need to use Windows Server due to the requirements of other program we need to use.

    However, as we are going to use Drupal 7, the PHP version will be 5.3 and not above that. We also need to use 64 bits version of MySQL due to database size.
    If I am going to need your help, how can I reach you?
    Please email to

    Looking forward to hearing from you.

    • newlife007 says:

      How can I help you out? You wanting to know how to install and configure them on Windows 2012? I think I can help you out. Also are you using IIS or APache for your web server?

  9. Hi! I really like how easy your guide is to follow, however, I can’t get it to work (using x64 vc11 bins, just slightly newer versions than yours). I just can’t get Apache to load with PHP because it fails to load the dll claiming it’s not a valid win32 program.
    “c:\Apache24>c:\Apache24\bin\httpd -S
    httpd: Syntax error on line 532 of C:/Apache24/conf/httpd.conf: Cannot load c:/p
    hp/php5apache2_4.dll into server: %1 is not a valid Win32 application.”
    The difference for me is that I’m running it on a Windows 8 x64 machine (will host it on a Win 10 x64 later).
    Any ideas on what to do to solve this?

  10. Janus Rokkjær says:

    And then it’s not working..
    c:/php/php5apache2_4.dll is not in the directory specified in the file and even if i add the file in the version working together i still get a 500 error.

    So needs an update or correction.

    • newlife007 says:

      Did you add c:\php to your environmental path values on the server? to PATH in Environment variables. PATH ENVIRONMENT (System Properties | Advanced | Environment Variables | System variables | Path).

      • scifibob says:

        It would be nice if you updated your post to mention these small additions.
        By the way, where do I find PATH ENVIRONMENT?

  11. Helena says:

    How do I check that PHP, Apache and MySQL work together. I want to install Joomla but the installer doesn’t work.

    • newlife007 says:

      What is the Joomla installer complaining about when you run it? What error is it giving you? In the installation instructions on this post there is a test for the PHP installation, For Apache opening Internet Explorer and typing in localhost for the URL should display the index.html page showing It Works!. For MySQL you should be able to open a command prompt and connect to MySQL.

  12. girl says:

    I have some issue
    1. I want to change root directory “DocumentRoot “e:/www” instead by default ,It’s can possible? and How to ?
    2. If question one it impossible! have author solution? and How to?

    • newlife007 says:

      In the c:\Apache24\conf\httpd.conf file find the DocumentRoot “c:/Apache24/htdocs” and change it to DocumentRoot “e:/www” this will change where the default content is put for the site. Save the changes and restart Apache service.

  13. MrMacvos says:

    Thanks for writing this post – it helped me out. I am new to installing this stuff on Windows (easy part, just a double-click) and getting it to work (not so easy part).

    So I mixed up VC9, VC11 and VC14 installations (wtf do I know), installed 5 versions of vcredist_x64 (from 2010 thru 2012), wanted to istall Apache 2.2 but could not find any 64bit PHP installation for it, etc, etc.. So, finding out the hard way, I stumbled upon your webpage and followed the steps. Got it working now! So, don’t move or delete this page!

  14. Rob says:

    I get the same error as Janus.
    c:/php/php5apache2_4.dll can not be found. When it is there.
    I setup multiple different apache/php combinations on different versions of windows. I find that depending on the exact apache/php combination you get this error. It may be because you combined 64 bit with 32 bit versions. But I have 64 bit versions together and I still get the error. If I solve it I will post here. I have it working on my other win2k12 box but just not this one with newer versions of Apache/Php

    • newlife007 says:

      Most times when I see this error is is due to the Windows Path not having c:\php in it and I have seen the newer versions of PHP make changes. Did you add the php settings in the Apache httpd.conf and another big piece is the VC++ version you downloaded matches the PHP compiled version. They have to match.

  15. Damien Howard says:

    Excellent, all up and running in under 3 hours (a little fiddling getting PHP up n running)

    Top Job!

  16. Charles parrington says:

    Hi All, I have done everything I can think of and followed the above suggestions but I am getting the following error and cannot seem to solve – when I try to test Apache or even install it as a service I get the “this program cannot start because VCRUNTIME140.dll is missing ……

    I have even found a copy of this dll and placed it in the Windows32 directory, but same error – any suggestions please.

  17. Erik says:

    Thanks dude, that was really helpfully, only change i made was not install phpmyadmin i prefer use mysqlworkbench, but this is a good guide..

  18. Adam says:

    I followed these directions updating the versions to the more recent ones. Everything is working so far except the final step. I put phpmyadmin in the htdocs folder and tried to load the page to finish the install andI get this error:
    Fatal error: Uncaught Error: Call to undefined function mb_detect_encoding() in C:\Apache24\htdocs\phpmyadmin\libraries\php-gettext\ Stack trace: #0 C:\Apache24\htdocs\phpmyadmin\libraries\php-gettext\ _encode(‘The %s extensio…’) #1 C:\Apache24\htdocs\phpmyadmin\libraries\php-gettext\ _gettext(‘The %s extensio…’) #2 C:\Apache24\htdocs\phpmyadmin\libraries\core.lib.php(306): __(‘The %s extensio…’) #3 C:\Apache24\htdocs\phpmyadmin\libraries\core.lib.php(961): PMA_warnMissingExtension(‘mbstring’, true) #4 C:\Apache24\htdocs\phpmyadmin\libraries\ PMA_checkExtensions() #5 C:\Apache24\htdocs\phpmyadmin\setup\lib\ require_once(‘C:\\Apache24\\htd…’) #6 C:\Apache24\htdocs\phpmyadmin\setup\index.php(13): require(‘C:\\Apache24\\htd…’) #7 {main} thrown in C:\Apache24\htdocs\phpmyadmin\libraries\php-gettext\ on line 177

    I went into the file but I can’t really make heads or tails of what line 177 is. Thoughts?

    • Adam says:

      I also just noticed that I cannot access the base site (index.html) from outside the server. I had IIS installed when I started this but I removed it. Do I need to do something to get it to redirect right?

      • Adam says:

        Scratch the issue with the base site. With IIS when I put in the IP, it went right to the home page. I didn’t realize with this I had to add \index.html to get it to load. But it’s loading with that.

  19. Bopert says:

    This info is spot-on for what I need. However, can I install WAMP (then WordPress) on my D drive instead? My virtual dedicated server’s C drive is almost filled up with the OS and IIS, and I have a 50GB D drive that is empty.

    • newlife007 says:

      You can install WAMP on any drive as long you define it during the install. As for this post you can install Apache and PHP to the drive as well just change the drive letter instead of using C:. The one thing you will need to do when running multiple instances of apache is to configure it to use a different port, all cant use port 80 and run at the sametime.

      • Bopert says:

        Thanks for your kind reply. He’re my dilemma: I am on the verge of going to market with a Windows App that relies on IIS for web services. This IIS is installed on the C drive and is working fine for its purposes. However, I want to stand up my website on Apache, as I’ve read that WordPress on IIS is less stable and has certain security vulnerabilities. So, port conflicts aside (which can be configured, as you mentioned), is it a good idea to have two different web servers on the same AWS instance?

        • Bopert says:

          To be more specific: the web services piece on IIS manages user account info in the cloud, and employs a SQL server database, also installed on the C drive.

          Ideally I want the entire WAMP stack, and all the WordPress files, on the D drive.

          Am I barking up the wrong tree with this approach?

        • newlife007 says:

          In past experiences it is always best to run separate and not IIS and Apache on the same instance. Windows is really suited for supporting a single application. It is easier to manage and gets rids of any conflicts. As for WordPress running on IIS I do not have any experience with it and really Linux is probably the best and most stable OS to run it on.

          • Bopert says:

            Thank you for your suggestions. I decided to snapshot, then expand my C volume size on AWS, and will run with WordPress on IIS on the root. Appreciate the tips!!

  20. Omar Lugo says:

    When i go to the last step for phpmyadmin I cant understand “Rename directory to phpmyadmin.” Do I rename the whole “apache24” to phpmyadmin or rename the htdocs. or the folder that has the long name which the php files are in. Im using this tutorial, but installing the latest stable for each of the programs. And for some reason whenever I type “localhost/phpmyadmin/setup/index.php” It just opens an error message on hfs that it wasnt found. Any ideas on what is wrong?

    • newlife007 says:

      The comment means rename extracted phpMyAdmin-4.6.6-english directory to phpmyadmin. So the final name will be c:\apache24\htdocs\phpmyadmin

      • Omar Lugo says:

        Thanks, on another note. If i am using php7 then on the first step should the edit to the apache config file look like this?

        LoadModule php7_module “c:/php/php7apache2_4.dll”
        AddHandler application/x-httpd-php .php
        # configure the path to php.ini
        PHPIniDir “C:/php”

  21. Flocka says:


    Where am I suppose to put the index.php file? I entered localhost/info.php in the browser and get error. Please help

    • newlife007 says:

      the file should be in c:\apache24\htdocs as that is the default location defined in the httpd.conf file. If you need to change it edit the c:\apache24\conf\httpd.conf file and edit the DocumentRoot variable.

      • Flocka says:

        What about the Listen variable? I can’t seem to bind with port 80. How am I suppose to do it?

        • newlife007 says:

          Do you have anything else running that would use port 80? For instance IIS? If you open your browser and go to http://localhost do you get the IIS welcome page? Run netstat command to see.
          C:\WINDOWS\system32>netstat -na | find /I “80”
          If you do then change the Listen to 8080 and restart Apache and in the browser type http://localhost:8080 and see if you get the Apache welcome page.

  22. x26 says:

    “Create a config directory under phpmyadmin” what config directory??

  23. Chris says:

    At the very end of tutorial i browse to http://localhost and I get “It works!” which mean the service is listening and responsive, but when I got to http://localhost/info.php I get “Not Found

    The requested URL /info.php was not found on this server.”

    What is wrong here?

  24. Alexis says:

    Thank you for this tutoriel.
    I succeed to install and use phpmyadmin and Mantis Bug tracker.

    Unfortunately, i have trouble in the SSL activation. No problem with the certificate installation, but trouble with the virtual host definition.

    Do you know a good Tutorial ?

    Thanks again

  25. Ian says:

    I was really hoping this tutorial would help me out but I’m 2 days in and still no joy.

    Tried following this line by line but cannot get Apache to run at all.
    Got the win32 dll message error, managed to resolve that by getting the VC14 x64 Thread Safe (2017-Aug-30 21:35:35) from
    but whenever I tried to start Apache from services.msc I just get a whole load of
    AH00015 Unable to open logs
    repeatedly checked I have ;c:\php;c:\apache24;c:\apache24\bin; in the Path Environment Variables as directed

    http://localhost with the info.php in the c:\Apache24\htdocs location doesn’t resolve either

    The setup I’m trying to get this working on is a virtual machine running Windows Server 2012

    • newlife007 says:

      Did you edit the httpd.conf and set a value for ServerName. You can set it to IPaddress of the system. Save the shanges and restart the Apache service.

      • Ian says:

        Hi – thanks for reply. I did manage to finally get apache running, multiple changes to the httpd.conf file…
        Listen 8080


        LoadModule php7_module “c:/php/php7apache2_4.dll”
        AddHandler application/x-httpd-php .php
        # configure the path to php.ini
        PHPIniDir “C:/php”

        For mySQL installation had issues re 4.5.2 version of .net as although I’m running x64 the instance only started working when installed the vcredist_x86 version. Also had the c++ redistributable issue

        So thanks again

  26. Rajkumar.G says:

    How to register SQLSRV in the php and apache. Its shows me not registered.

  27. Fractioncalc says:

    I am having this problem “Your PHP installation appears to be missing the MySQL extension which is required by WordPress” when I’m upgrade the php from version 5.6 to 7.2. Turns out that mysql extension is no longer supported in php version 7.2. It is now using mysqli extension. I am using old version of wordpress which still using mysql extension so the problem existed. So what I did is upgraded the wordpress to the core. I used the latest version of wordpress and used filezilla to put the new version to the site. I only overwrite the folder wp-includes and wp-admin and replace all the files in the root folder with the new files from version 7.2

    • newlife007 says:

      The mySQL extensions are included in the PHP download. You have to edit the PHP.ini as in the post and make sure the extensions= has the correct sub directory. When I wrote this post it was in the c:\php\ext directory.

    • newlife007 says:

      I should have read more before responding earlier. Looks like WordPress 5.1.1 has a few different requirements. e recommend servers running version 7.3 or greater of PHP and MySQL version 5.6 OR MariaDB version 10.0 or greater. Download PHP 7.3 (7.3.3) from here and only uncomment extension=php_mysqli.dll

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.