Table of Contents

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

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

Unzip and move

C:\Apache24

Add the php home directory path into the user and system path

On windows, from 7.4, the sqlite extension needs to get access to the libsqlite3.dll that is located into the php directory.

If you are running the service with the system path, you should add the php home directory in the system path.

Php Home Path System User

Create the service

cd C:\Apache24\bin
httpd -k install
httpd -k start

Apache Service Windows

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

On Windows, to be able to load the intl extension (localization), you need also to add the ICU file. In the documentation, they said that you can also set them on the LD_LIBRARY_PATH.

LoadFile  "C:\php-7.2.28-Win32-VC15-x64\icudt64.dll"
LoadFile  "C:\php-7.2.28-Win32-VC15-x64\icuin64.dll"
LoadFile  "C:\php-7.2.28-Win32-VC15-x64\icuio64.dll"
LoadFile  "C:\php-7.2.28-Win32-VC15-x64\icuuc64.dll"

Then:

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>

FastCGI

If you want to boost your performance, FastCGI is the way to go. See this article that shows how to install it

Support

PHP Startup: Unable to load dynamic library 'intl'

If you get this error in the log:

php -m
LoadFile  "C:\php-7.2.28-Win32-VC15-x64\icudt64.dll"
LoadFile  "C:\php-7.2.28-Win32-VC15-x64\icuin64.dll"
LoadFile  "C:\php-7.2.28-Win32-VC15-x64\icuio64.dll"
LoadFile  "C:\php-7.2.28-Win32-VC15-x64\icuuc64.dll"

Module not loading

For whatever reason, Apache locates the extension directory from the working directory. In the php.ini, be sure to put the qualified path.

extension_dir = "c:\php-7.2.28-Win32-VC15-x64\ext"

Sqlite module not loading

Be sure to add your php home directory into the user/system path that runs Apache. See bug 78957

Documentation / Reference