### Apache HTTP Server

# Compiling Apache for Microsoft Windows

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 6.0 to be properly installed. It can be built with command-line tools, or within the Visual Studio environment. 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, and the setenv.bat file from the Platform SDK, may be required to prepare the command-line tools for command-line builds (e.g. using nmake). To install apache with the Makefile.win or the InstallBin project in the Visual Studio IDE, the awk utility is also required. If you use Visual Studio 7.0 (.net), loading Apache.dsw converts it to .msproj format. When changes are made to the project (.dsp) files, you must reconvert Apache.dsw all over again.

First, you should install awk.exe where it can be found in the path and the DevStudio environment, if you plan to use the IDE. There are many versions of awk available for Windows; the easiest to install is available from Brian Kernighan's http://cm.bell-labs.com/cm/cs/who/bwk/ site. When downloading http://cm.bell-labs.com/cm/cs/who/bwk/awk95.exe from this site, you must save it with the name awk.exe rather than awk95.exe.

Note that Developer Studio IDE will only find awk.exe from the Tools menu Options... Directories tab (the Projects - VC++ Directories pane in Developer Studio 7.0) listing Executable file paths. Add the path for awk.exe to this list, and your system PATH environment variable, as needed.

Then 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 NT, 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.

If you get an error such as "the name specified is not recognized..." then you need to run vcvars32.bat first. Enter the following command;

      "c:\Program Files\DevStudio\VC\Bin\VCVARS32.BAT"

(you will need to adjust this command so it matches the directory where your VC was installed.)

If you are a Visual C++ 5.0 user, and have installed a recent Platform SDK, you may also need to enter the following command (adjusted for the install directory of the Platform SDK update);

      "c:\Program Files\Platform SDK\SETENV.BAT"

Then try the nmake command again.

Note that the Windows Platform SDK update is required to enable all supported mod_isapi features. The SDK files distributed with Microsoft Visual C++ 5.0 are out of date. Without a recent update, Apache will issue warnings under MSVC++ 5.0 that some mod_isapi features will be disabled. Look for the update at http://msdn.microsoft.com/platformsdk/.

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. InstallBin is the top-level project that will build all other projects, and install the compiled files into their proper locations.

These .dsp project files are distributed in Visual C++ 6.0 format. Visual C++ 5.0 (97) will recognize them with the single exception of the /ZI flag, which corresponds to the VC 5.0 /Zi flag for debugging symbols. To quickly prepare the .dsp files for the Visual Studio 5.0 (97), you can use the perl scripts distributed in the `src\helpers` folder:

      cd src\helpers
      cvstodsp5.pl

This command assumes you have a Perl interpreter installed and registered for files of type .pl. The list of converted .dsp project files will be displayed as they are converted. If you contribute back a patch that offers revised project files, please convert them back with the script dsp5tocvs.pl, which puts the projects back to Visual Studio 6.0 format.

The core .dsp projects built by Apache.dsw and makefile.win are:

- `os\win32\ApacheOS.dsp`
- `os\win32\Win9xConHook.dsp`
- `regex\regex.dsp`
- `ap\ap.dsp`
- `lib\expat-lite\xmltok.dsp`
- `lib\expat-lite\xmlparse.dsp requires xmltok`
- `lib\sdbm.dsp`
- `main\gen_uri_delims.dsp`
- `main\gen_test_char.dsp`
- `ApacheCore.dsp requires all of the above`
- `Apache.dsp requires ApacheCore`

In addition, the `os\win32` subdirectory contains project files for the optional modules, all of which require ApacheCore.

- `os\win32\mod_auth_anon.dsp`
- `os\win32\mod_auth_dbm.dsp also requires sdbm`
- `os\win32\mod_auth_digest.dsp`
- `os\win32\mod_cern_meta.dsp`
- `os\win32\mod_digest.dsp`
- `os\win32\mod_expires.dsp`
- `os\win32\mod_headers.dsp`
- `os\win32\mod_info.dsp`
- `os\win32\mod_mime_magic.dsp`
- `os\win32\mod_proxy.dsp`
- `os\win32\mod_rewrite.dsp`
- `os\win32\mod_speling.dsp`
- `os\win32\mod_status.dsp`
- `os\win32\mod_unique_id.dsp`
- `os\win32\mod_usertrack.dsp`
- `os\win32\mod_vhost_alias.dsp`

The `support\` folder contains project files for additional programs that are not part of the Apache runtime, but are used by the administrator to maintain password and log files.

- `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 install the files into the `c:\ServerRoot` directory automatically, use one of the following nmake commands (see above):

- `nmake /f Makefile.win installr INSTDIR=c:\ServerRoot` (for release build)
- `nmake /f Makefile.win installd INSTDIR=c:\ServerRoot` (for debug build)

The c:\ServerRoot argument to INSTDIR gives the installation directory (it can be omitted if Apache is to be installed into `\Apache`).

This will install the following:

- `c:\ServerRoot\Apache.exe` - Apache program
- `c:\ServerRoot\ApacheCore.dll` - Apache runtime [shared library]
- `c:\ServerRoot\Win9xConHook.dll` - Win9x console fixups [shared library]
- `c:\ServerRoot\xmlparse.dll` - XML parser [shared library]
- `c:\ServerRoot\xmltok.dll` - XML token engine [shared library]
- `c:\ServerRoot\bin\*.exe` - Administration programs
- `c:\ServerRoot\cgi-bin` - Example CGI scripts
- `c:\ServerRoot\conf` - Configuration files directory
- `c:\ServerRoot\icons` - Icons for FancyIndexing
- `c:\ServerRoot\include\*.h` - Apache header files
- `c:\ServerRoot\htdocs` - Welcome index.html pages
- `c:\ServerRoot\htdocs\manual` - Apache documentation
- `c:\ServerRoot\lib` - Static library files
- `c:\ServerRoot\libexec` - Dynamic link libraries
- `c:\ServerRoot\logs` - Empty logging directory
- `c:\ServerRoot\modules\mod_*.dll` - Loadable Apache modules

If you do not have nmake, or wish to install in a different directory, be sure to use a similar naming scheme.

To simplify the process, dependencies between all projects are defined in the Microsoft Visual Studio workspace file:

       src/Apache.dsw

This assures that lower-level sources are rebuilt from within Visual Studio. 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. Modify the InstallBin settings and edit the INSTDIR=.. entry to the desired target directory.

### Apache HTTP Server