There are many important points before you begin compiling Apache. See Using Apache with Microsoft Windows before you begin.
Compiling Apache requires Microsoft Visual C++ 5.0 (or later) to be properly installed. It is easiest to compile with the command-line tools (nmake, etc...). Consult the VC++ manual to determine how to install them. Be especially aware that the vcvars32.bat file from the Program Files/DevStudio/VC/bin folder may be required to prepare the command-line environment for command-line builds!
First, unpack the Apache distribution into an appropriate
directory. Open a command-line prompt, and change to the
src
subdirectory of the Apache distribution.
The master Apache makefile instructions are contained in the
Makefile.win
file. To compile Apache on Windows, simply
use one of the following commands:
nmake /f Makefile.win _apacher
(release build)
nmake /f Makefile.win _apached
(debug build)
These will both compile Apache. The latter will include debugging information in the resulting files, making it easier to find bugs and track down problems.
Apache can also be compiled using VC++'s Visual Studio development environment. To simplify this process, a Visual Studio workspace, Apache.dsw, is provided in the src folder. This workspace exposes the entire list of working .dsp projects that are required for the complete Apache binary release. It includes dependencies between the projects to assure that they are built in the appropriate order.
Notice: The Apache/VisualStudio project files are distributed in VisualStudio 6.0 (98) format. In fact you may build with VisualStudio 5.0 (97) but you must first use the perl script command:
cd src\helpers cvstodsp5.pl
Without running the script you will be able to load and build Apache,
however VisualStudio 97 in particular will not recognize the /ZI flag
to the C compiler for the debugging mode. This script toggles the
new /ZI flag back to /Zi for Debug builds, among other adjustments.
The converse script in src/helpers/dsp5tocvs.pl
will
reverse the adjustments, and we ask you to do so before submitting
patches against any .dsp project files.
The Apache.dsw workspace and makefile.win nmake script both build the .dsp projects of the Apache server in the following sequence:
lib\apr\aprlib.dsp
lib\apr\aprlibdll.dsp requires aprlib
lib\pcre\dftables.dsp
lib\pcre\pcre.dsp requires dftables
lib\pcre\pcreposix.dsp requires dftables and pcre
lib\expat-lite\xmltok.dsp
lib\expat-lite\xmlparse.dsp requires xmltok
main\gen_uri_delims.dsp
main\gen_test_char.dsp
ApacheCore.dsp requires all of the above
Apache.dsp requires ApacheCore and aprlibdll
os\win32
subdirectory contains
project files for the optional modules.
os\win32\ApacheModuleAuthAnon.dsp
os\win32\ApacheModuleAuthDigest.dsp
os\win32\ApacheModuleCERNMeta.dsp
os\win32\ApacheModuleExpires.dsp
os\win32\ApacheModuleFileCache.dsp
os\win32\ApacheModuleHeaders.dsp
os\win32\ApacheModuleInfo.dsp
os\win32\ApacheModuleRewrite.dsp
os\win32\ApacheModuleSpeling.dsp
os\win32\ApacheModuleStatus.dsp
os\win32\ApacheModuleUserTrack.dsp
modules\proxy\ApacheModuleProxy.dsp
support\
folder contains project files for additional
programs that are not part of the apache runtime, but are used by
the administrator to test Apache and maintain password and log files.
support\ab.dsp
support\htdigest.dsp
support\htpasswd.dsp
support\logresolve.dsp
support\rotatelogs.dsp
Once Apache has been compiled, it needs to be installed in its server
root directory. The default is the \Apache
directory, on the current hard drive.
To build and install all the files into the desired folder dir automatically, use one the following nmake commands:
nmake /f Makefile.win installr INSTDIR=dir
(for release build)
nmake /f Makefile.win installd INSTDIR=dir
(for debug build)
This will install the following:
dir\Apache.exe
- Apache executable
dir\aprlib.dll
- Apache Portable Runtime shared library
dir\ApacheCore.dll
- Apache Core application
dir\modules\ApacheModule*.dll
- Loadable Apache
modules
dir\bin\*.exe
- Administrator support executables
dir\conf
- Empty configuration directory
dir\logs
- Empty logging directory
If you do not have nmake, or wish to install in a different directory, be sure to use a similar naming scheme, or use the following shortcut.
To simplify the process, dependencies between all projects are defined in the Microsoft VisualStudio workspace file:
src/Apache.dsw
This assures that lower-level sources are rebuilt from within VisualStudio. The top level project is InstallBin, which invokes Makefile.win to move the compiled executables and dlls. You may personalize the INSTDIR= setting by changing the Settings for InstallBin, Build command line entry under the General tab. The default from within the InstallBin.dsp project is one level up (..) from the src tree.
Warning about building Apache from the development tree
Only the .dsp files are distributed between release builds. The .mak files are NOT regenerated, due to the tremendous waste of reviewer's time. Therefore, you cannot rely on the NMAKE commands above to build revised .dsp project files unless you then export all .mak files yourself from the project. This is unnecessary if you build from withing the Microsoft DeveloperStudio environment.
Before running the server you must fill out the conf directory. Copy the *.conf-dist-win from the distribution conf directory and rename *.conf. Edit the @@ServerRoot@@ entries to your actual server root (for example "C:\apache"). Copy over the conf/magic and conf/mime.types files as well.