Apache - Windows Installation

About

This article is a succession of step by step that shows you how to install Apache on Windows.

This article was done with the following application version but the principe stays and should work with all version

  • Windows 10
  • Apache 2.4

Steps

Download the binary

The Apache project does not provide the Windows binary.

The download php page recommends to use apachelounge because they use their binaries to build the Apache SAPIs.

Download the last binary at apachelounge

Example:

httpd-2.4.46-win64-VS16.zip
  • VC15 stands for Visual Studio Compiler Version 15
  • VS16 for Visual Studio 16

Unzip and move

  • Unzip it (The file readme_first.html is the installation guide and is summarized below)
  • Copy the file to
C:\Apache24

Create the service

  • Start the command prompt as admin
  • Install the service and start it with the httpd binary
cd C:\Apache24\bin
httpd -k install
httpd -k start

  • A welcome page should also be seen at http://localhost. This page is located at: C:\Apache24\htdocs

There is more options. See the documentation

Configuration

Server Name

To get access to the main server:

ServerName local

Rewrite Module

The rewrite module permits to have nice url and is generally used.

Uncomment the line

LoadModule rewrite_module modules/mod_rewrite.so

Virtual host

Add virtual host

ServerName serverName

# Virtual Host
Include conf/extra/httpd-vhosts.conf

Php

Add php as module of Apache in the httpd.conf file

LoadModule php7_module "C:/php-7.2.28-Win32-VC15-x64/php7apache2_4.dll"
AddType application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php-7.2.28-Win32-VC15-x64"

<Directory "C:/php-7.2.28-Win32-VC15-x64/" >
    AllowOverride None
    Options None
    Require all granted
</Directory>

Documentation / Reference


Powered by ComboStrap