Installing Apache 2.4 and PHP 7 for Development on Windows

In this post I’m going to explain how to install Apache and PHP without using the WAMP or XAMPP distributions, I’m using this approach because I think you can have more control over configurations, modules and services installed.

Installing Apache 2.4.25

  1. To download Apache you have two popular options: Apache Lounge or Apache Haus. Go to the download section of any of this projects located on Apache Lounge or Apache Haus, just make sure:
    • To choose the binary distribution.
    • Download the binaries that matches your operative system bitness (32 or 64 bit).

      Apache x86/x64 Download (Apache Lounge Screenshot)

    At the moment of writing this post I’ve used Apache Lounge binaries because they are compiled with the latest Windows Visual Studio C++ 2015 (VC14).

  2. Then download and install the Microsoft Visual C++ 2015 Redistributable Update 3 (VC14) version 14.0.24215.
  3. Unzip Apache binaries to the C:\Apache24 folder.
  4. To install Apache as a Windows service you have to open the command prompt window (cmd.exe) as administrator and execute:
    rem # Or whatever path you unzipped the Apache files
    cd "C:\Apache24\bin"
    rem #Command to install Apache 2.4 as a Windows Service
    httpd.exe -k install -n "Apache 2.4"

    If you do this you can use the Apache Monitor (located at C:\Apache24\bin\ApacheMonitor.exe) to start and stop Apache.

Installing PHP 7

  1. To get the latest stable version download the thread safe binaries from the PHP for Windows site. You can always download a release candidate at the QA site (if you downloaded the 32 bit version of Apache then download PHP x86, don’t mix versions).

    Other common question is whether you should download the thread safe or non-thread safe PHP version, I’m using the thread safe version, because on the Windows PHP main site says:

    If you are using PHP as FastCGI with IIS you should use the Non-Thread Safe (NTS) versions of PHP.

  2. Then unzip the PHP binaries to the C:\php7 folder.

Configure Apache

  1. Open the Apache Configuration file C:\Apache24\conf\httpd.conf
  2. Locate the ServerRoot to configure the server root to c:/Apache24, the following should be used:
    ServerRoot "c:/Apache24"

    Remember to use slashes “/” instead of backslashes “\” on the path.

  3. Locate the Listen string to configure port of Apache to 8080, the following can be used:
    Listen 8080

    You can use telnet to see which port is available in your computer.

  4. Locate the DocumentRoot to configure the directory from which Apache will serve pages to c:/Apache24/htdocs, the following should be used:
    DocumentRoot "c:/Apache24/htdocs"
    <Directory "c:/Apache24/htdocs">
  5. Copy the following lines on the top of the file:
    AddHandler application/x-httpd-php .php
    AddType application/x-httpd-php .php .html
    LoadModule php7_module "c:/php7/php7apache2_4.dll"
    PHPIniDir "c:/php7"

Configure PHP

  1. The only thing you have to do is to rename the file C:\php7\php.ini-development to C:\php7\php.ini. It’s a good idea to make a backup of this file as well.

Testing the Apache and PHP Installation

  1. You have to start Apache Windows service, to do this, use Apache monitor C:\Apache24\bin\ApacheMonitor.exe.
    The other alternative is to open the command prompt window (cmd.exe) as administrator and execute:

    rem #Command to start the Apache Windows service
    net start "Apache 2.4"

    And the last alternative is to use the services console (services.msc).
    I use the first option.

  2. Create the following text file C:\Apache24\htdocs\phpinfo.php:

    Then go to your browser and write http://localhost:8080/phpinfo.php, this page should show the details of your PHP installation.

Troubleshooting Apache

Configuration Problems

If you have any problem when starting Apache because of its configuration, you can see the detailed error by executing:

rem # Or whatever path you unzipped the Apache files
cd "C:\Apache24\bin"

rem #Command to install Apache 2.4 as a Windows Service
httpd.exe -t

The -t parameter test the syntax of the configuration files, and then exits.

You can find the specification of the others parameteres here.

Tagged with: , , ,
Publicado en Apache, PHP, Windows
22 comments on “Installing Apache 2.4 and PHP 7 for Development on Windows
  1. 孙德旺 dice:

    “AddType application/x-httpd-php .html .html” is wrong,should be “AddType application/x-httpd-php .php .html”

  2. Hi I had an issue pasting those config lines into httpd.conf. It turns out the quotemark characters used in this page need to be re-typed manually

  3. Thank you so much, Man! 🙂

  4. […] Installing Apache 2.4 and PHP 7 for Development on Windows […]

  5. Thank you for this guide! It worked fantastically.

  6. In the zip, mentioned in the “VC14 x64 Thread Safe (2016-Feb-17 22:49:08)” build on, no php7apache*.dll can be found 😦

  7. rmiles7721 dice:

    Thanks for the help. The directions I had found online prior to this were confusing and didn’t work but this worked like a charm.

  8. anjanesh dice:

    I came back to Windows (Windows 10) after a 8 year gap of using Ubuntu-only machine and was struggling with installing Apache + PHP. This is the most to-the-point tutorial I’ve come across and it worked well for me. Thanks !

  9. For developing and testing PHP7 applications, this is my favourite tool:

  10. Betty Rubio dice:

    Gracias no podía hacer funcionar apache 😉

  11. kclaytor2 dice:

    Thanks so much. I was having trouble getting it to work, but following your guide made it work for me!

  12. Don Alejandro dice:

    Thanks Daniel – I needed to update my testing server, which has been running on 15-year old versions of Apache/php that were available as .msi files, so I needed some guidance.

    There does seem to be one more step that should probably be added. I’m mostly running WordPress sites on my testing server, which requires the curl extension to be enabled in order to update plugins and itself. Apparently, on windows systems, the curl extension (and possibly others) won’t work properly unless the c:\php7\ directory is added to the windows system environment PATH variable.

    Here is a thread that talks about getting the curl extension to work:

    One of the suggestions was to copy a couple dll files to /windows/system32, which sort of worked to enable curl – wordpress updates worked, but the curl block still wouldn’t show up in phpinfo() until after I added c:\php7\ to the PATH (and restarted windows), which was suggested later in the thread. Of course, if the php directory is added to the PATH it’s not necessary to copy any dll files to /windows/system32.

    I’ll also note that when I looked at the PATH variable, the path to my old php5 directory was the very first directory in the PATH, so the ancient .msi installer files I used must have put it there, which is another good indication that this is important on a windows system. I’m not sure if the php directory has to be first, but curl didn’t work when I added the php7directory to the end of the path, so I put ‘C:\php7\;’ at the beginning of the PATH variable and everything worked, including the curl block in phpinfo().

  13. Bruno Mateus dice:

    Thank you so much! I needed to develop locally for Drupal 8, and I always used xampp. But for Windows they only have 32 bit versions, and Drupal 8 needs the 64bit version of php7 for full performance.

    Your instructions allowed me to replace the Apache and php with the 64bit versions 🙂
    Thanks !!!

  14. Lionello Santi dice:

    Thanks but you forgot to mention this index.php needs to be added here too:

    DirectoryIndex index.php index.html

Puedes dejar un comentario

Por favor, inicia sesión con uno de estos métodos para publicar tu comentario:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google photo

Estás comentando usando tu cuenta de Google. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios .

A %d blogueros les gusta esto: