Charles Engelke's Blog

May 8, 2004

Building Apache

Filed under: MSVC — Charles Engelke @ 10:44 am

I posted some
notes
about building Perl with
Microsoft’s
free C++ development tools
. Today I’m rebuilding my PC, and
I’m using my own Apache build instead of their binary. Here’s what
I had to do.

First, unzip the Apache source to a folder that doesn’t have any
blanks in its name. Then unpack the latest
OpenSSL
source in the srclib subdirectory of your Apache
source. Then unpack zlib
1.1.4
(not the latest version, which changed the DLL
structure) in the srclib subdirectory, too. Rename
the OpenSSL folder simply openssl, and the zlib
folder just zlib.

Build OpenSSL by changing to the openssl folder
you unpacked above. Then type the following commands (you’ll need
Perl installed first):

perl Configure VC-WIN32
perl util\mkfiles.pl >MINFO
perl util\mk1mf.pl dll no-asm no-mdc2 no-rc5 no-idea VC-WIN32 >makefile
perl util\mkdef.pl 32 libeay no-asm no-mdc2 no-rc5 no-idea >ms\libeay32.def
perl util\mkdef.pl 32 ssleay no-asm no-mdc2 no-rc5 no-idea >ms\ssleay32.def

Now edit the makefile you just created, and replace
the line that reads APP_EX_OBJ=setargv.obj with
APP_EX_OBJ=. (That dot at the end isn’t part of the
line you need, it’s just the end of the sentence.) I don’t know why you need to do this,
but I had to. Next, build OpenSSL by typing nmake.

Build zlib by changing to the zlib folder you
created above. Copy all the files in the nt
subdirectory of the zlib to the main zlib
folder. Then build the zlib DLL with the command nmake
-f Makefile.nt
.

Now we’re ready to build Apache. Change to your Apache source
directory, and type nmake /f Makefile.win _apacher.
Once that’s done, install Apache to the folder of your choice with
nmake /f Makefile.win installr INSTDIR=somedirnam,
where somedirname is the folder you want Apache installed
to. For some reason, the Apache manual didn’t get built right for
me.

Now you can change to the bin subdirectory of your
Apache installation directory, and start Apache by typing
Apache. Test it with a web browser, then kill
it by hitting Control-C a few times. You can test different
configuration files by specifying the conf file name after a
-f parameter. Test SSL (which will require you
to edit the ssl.conf file and set up a server key and certificate,
which I won’t cover here) by using the -DSSL
parameter.

When you’re happy with your Apache configuration, install it as a
Windows service by using the same command line you had before, but
adding -k install to the command line. If you
want to give your own name to the service, add -n name
to the command line. The entire command line I used was:

apache -f "c:\My Documents\Apache\conf\httpd.conf" -DSSL -k install -n ApacheWithSSL

Apache will start automatically whenever you boot your PC. Force it
to start now without rebooting with the command apache -k start.

After you’re sure everything is stable and working, go ahead and
delete the source folders you created for the build.

Advertisement

Blog at WordPress.com.

%d bloggers like this: