### 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 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 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.) Then try the nmake command again.

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.

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 that are build by Apache.dsw or makefile.win are:

1. `os\win32\ApacheOS.dsp`
2. `regex\regex.dsp`
3. `ap\ap.dsp`
4. `lib\expat-lite\xmltok.dsp`
5. `lib\expat-lite\xmlparse.dsp requires xmltok`
6. `main\gen_uri_delims.dsp`
7. `main\gen_test_char.dsp`
8. `ApacheCore.dsp requires all of the above`
9. `Apache.dsp requires ApacheCore`

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

1. `os\win32\ApacheModuleAuthAnon.dsp`
2. `os\win32\ApacheModuleAuthDigest.dsp`
3. `os\win32\ApacheModuleCERNMeta.dsp`
4. `os\win32\ApacheModuleDigest.dsp`
5. `os\win32\ApacheModuleExpires.dsp`
6. `os\win32\ApacheModuleHeaders.dsp`
7. `os\win32\ApacheModuleInfo.dsp`
8. `os\win32\ApacheModuleRewrite.dsp`
9. `os\win32\ApacheModuleSpeling.dsp`
10. `os\win32\ApacheModuleStatus.dsp`
11. `os\win32\ApacheModuleUserTrack.dsp`
12. `modules\proxy\ApacheModuleProxy.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.

1. `support\htdigest.dsp`
2. `support\htpasswd.dsp`
3. `support\logresolve.dsp`
4. `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 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 executable
- `c:\ServerRoot\ApacheCore.dll` - Main Apache shared library
- `c:\ServerRoot\modules\ApacheModule*.dll` - Loadable Apache modules
- `c:\ServerRoot\bin\*.exe` - Administrator support executables from support
- `c:\ServerRoot\conf` - Empty configuration directory
- `c:\ServerRoot\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.

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.

Before running the server you must fill out the conf directory. Copy the *.conf-dist-win from the distribution conf directory and rename them to *.conf. You will need to copy over the conf/magic and conf/mime.types files as well. In order to serve documents you will need to create a htdocs\index.html or just copy over the standard Apache ones (This is a good idea as then you get the full Apache documentation on line). If you have previously run Apache from the c:\ServerRoot directory then please make sure you backup any files you wish to retain or only copy the files you want replaced. The following commands will copy all the required files to your c:\ServerRoot directory (***over-writing any that were there***);

- `xcopy ..\conf\*.conf-dist-win c:\ServerRoot\conf\*.conf`
- `xcopy ..\conf\magic c:\ServerRoot\conf\`
- `xcopy ..\conf\mime.types c:\ServerRoot\conf\`
- `xcopy ..\htdocs\*.* c:\ServerRoot\htdocs\ /s`

(adjust these so c:\ServerRoot matches the INSTDIR used above.)

Change the @@ServerRoot@@ entries in c:\ServerRoot\conf\httpd.conf to your actual server root (for example "c:/ServerRoot" Note: you must use forward slashes in Apache configuration files!)

### Apache HTTP Server