internals:windows:libs:apache22

Build Apache 2.2.x on Windows

Requirements

Knowledge

You do not need to have previous knowledge of the tools. Basic notions about compilation and using comand line tools should be enough.

Development environment (software)

Here is a list of the tools needed to compile Apache and its dependencies under Windows:

You will need to take certain actions in order to simplify the rest of the procedure:

Microsoft Windows SDK v6.1

In the folder C:\Program Files\Microsoft SDKs\Windows\v6.1\Include, copy the WinResrc.h file to winres.h. Note: This modification is not required to compile Apache but it solves frequent compilation problems due to the evolution of development environments and the SDKs provided by Microsoft.

Awk

The binary needs to be called awk.exe and available through the PATH. Copy it under the Visual C++ binaries folder, ie. C:\Program Files\Microsoft Visual Studio 9.0\VC\bin

Source files

Here is the list of the sources for Apache and its dependencies:

Note: I would recommend that you always download source files (as with any tool, software etc.) from the official website.

Awk

Preparation

The zlib library is used to compile mod_deflate and OpenSSL. Its compilation is simple and looks more like a formality than anything. Say we are working with a folder C:\httpd_build created for the occasion: let's uncompress zlib into C:\httpd_build\zlib

Compilation

Open a Visual Studio 2008 command prompt and go to the folder we just talked about. To start the compilation, do the following:

nmake -f win32\Makefile.msc

Compilation finishes relatively fast. Execute the following line to check that everything went fine:

nmake -f win32\Makefile.msc test

This command should return someting like:

zlib version 1.2.3 = 0x1230, compile flags = 0x55
uncompress(): hello, hello!
gzread(): hello, hello!
gzgets() after gzseek:  hello!
inflate(): hello, hello!
large_inflate(): OK
after inflateSync(): hello, hello!
inflate with dictionary: hello, hello!
        echo hello world | minigzip | minigzip -d
hello world

OpenSSL

Preparation

OpenSSL is used to compile mod_ssl as well as ApacheBench/SSL. Let's uncompress the source archive in another folder than the working folder, for instance C:\httpd_build\OpenSSL. Then go to the folder C:\httpd_build\OpenSSL\crypto\sha\asm and edit the sha1-586.pl file: on line 152, you need to remove the second declaration argument so as to end up with the following code:

&function_begin("sha1_block_data_order");

Once the file is modified, let's move on to compilation configuration. From the command line, go to C:\httpd_build\OpenSSL and execute:

perl Configure no-mdc2 no-rc5 no-idea enable-zlib VC-WIN32 -I../zlib

This command allows us to deactivate portions of the code that are under patent, to say that we will be using MS Visual C++ for a 32 bits platform and to give the path to the zlib we just compiled. If you intend to compile PHP (with SSL) afterwards, you may want to check that the options are the same. A standard PHP compilation with OpenSSL does not deactivate patented code.

Assembly code (ASM) compilation

OpenSSL source code has multiple versions of at least two languages: assembly and C. Here we will follow Apache documentation's guidelines and we will compile the functions using assembly code. The versions coded in C will not be included in the resulting binaries.

Preparation (again)

The makefile (info) generated with the previous step needs to be modified so that the operation can be a success. Open the ntdll.mak located under the ms folder, look for the line containing “zlib1.lib” and replace by “C:/httpd_build/zlib/zdll.lib” (watch out, those are forward slashes) so as to get something like:

$(SHLIB_EX_OBJ) $(CRYPTOOBJ)  wsock32.lib gdi32.lib advapi32.lib user32.lib C:/httpd_build/zlib/zdll.lib

If you deactivated patented code, you now need to modify the testsuite so that it does not fail. Remove the following lines from test.bat:

echo ideatest
ideatest
if errorlevel 1 goto done

Compilation

Let's compile the functions that are coded only in C. From the command line, go to C:\httpd_build\OpenSSL and execute:

nmake -f ms\ntdll.mak

This step is quite long but it should finish without any error message. Once compilation is done, start the tests to check OpenSSL works fine:

nmake -f ms\ntdll.mak test

All the tests will execute. If everything goes well, the last line will be:

passed all tests

Apache

Preparation

We near the end. Uncompress the apache sources under a new folder of our workspace, for instance C:\httpd_build\httpd. While compiling, Apache will automatically detect zlib and OpenSSL if they are located under srclib in the Apache folder and if they are named “zlib” and “OpenSSL”. Then let's copy the folders at the right place but do not “move” them so that you can reuse them when you need to compile Apache's next version ;)

Our working folder should look like this:

C:\httpd_build\ --- zlib\ ...
                 |- OpenSSL\ ...
                 |- httpd\ --- ...
                            |- srclib\ --- ...
                                        |- zlib\ ...
                                        |- OpenSSL\ ...

Compilation

Various commands and compilation options are available, and the command line will vary depending on your needs.

Compilation command syntax:

nmake -f Makefile.win option1=value options2=value ... command

Compilation commands:

_apacher    compile Apache as Release
_apached    compile Apache as Debug
installr    compile and install Apache as Release
installd    compile and install Apache as Debug
clean       delete (as many as possible) generated files
_cleanr     delete (as many as possible) files generated by a Release compilation
_cleand     delete (as many as possible) files generated by Debug compilation
_browse     browses the compilation information file

Compilation options:

Option      Default value
INSTDIR     \Apache22
PORT        80
SSLPORT     443
DOMAINNAME  example.com
SERVERNAME  www.example.com
SERVERNAME  admin@example.com

The following command is built to instruct Apache to be installed under C:\httpd_build\Apache22. From the command line prompt, go to C:\httpd_build\httpd and run:

nmake /f Makefile.win INSTDIR="C:\httpd_build\Apache22" installr

Like with OpenSSL, compilation takes some time but it should end without errors.

internals/windows/libs/apache22.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1