Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: How to Build Apache Mod SSL 2.2.n Using Visual C++ Express |
|
Author |
|
rkenning
Joined: 22 Aug 2006 Posts: 1 Location: Fairfax, VA
|
Posted: Fri 08 Sep '06 0:43 Post subject: How to Build Apache Mod SSL 2.2.n Using Visual C++ Express |
|
|
Successfully compiled, installed, and ran Apache2.2 with OpenSSL. Initially, I missed a few things such as commenting out Makefile.win and applying DSP patches. So, building Apache using the IDE worked better after getting over these humps.
For what it's worth, here are the build/install procedures based on rbeede's first draft, pnllan's notes, and a few embellishments.
Cheers,
Bob K.
How to Build Apache Mod SSL 2.2.n Using Visual C++ Express
This provides a description of how to build Apache 2.2.n with OpenSSL 0.9.n and mod_deflate (zlib 1.2.3) using Visual C++ 2005 Express Edition on Windows XP (or any 32-bit windows). Also, basic steps are provided to setup and run Apache with Mod SSL enabled.
Setup the Build Environment
Download and install Visual C++ 2005 Express Edition. Follow all instructions provided online, particularly the SDK installation instructions "Using Visual C++ 2005 Express Edition with the Microsoft Platform SDK". If you have installed the SDK correctly then you should be able to create a project that produces a primitive Windows application.
Download and install Perl (ActiveState version 5.8.3 or better). Confirm/set a system Path entry for it. Perl will be used to configure OpenSSL.
Download and rename awk95.exe to awk.exe -- see the awk utility (awk, gawk or similar). Add it to your system PATH so Visual Studio will see it. To save a step just move it to the ..\Perl\bin directory since its path is already set.
Download and install Microsoft Assembler (MASM) if you do not have Windows XP Pro. MASM will be used to compile OpenSSL. Or, download and install NASM (nasm-0.98.nn-win32.zip). For NASM, simply copy it to a directory and create a system PATH to it. Or, to save a step just move it to the ..\Perl\bin directory since its PATH is already set.
Create a workspace directory such as C:\Workspace\apache_mod_ssl\. This will be convenient spot to download, extract, and move the following files:
Download HTTP server Win32 source (httpd-2.2.n-win32-...zip) from Apache.org. Extract httpd-2.2.n-win32-src-rev2.zip, move/copy and rename it to ..\apache_mod_ssl\httpd-2.2.n
Download openssl-0.9.n.tar.gz source from OpenSSL.org. I ran into problems with a Zip version from another site. So, it's probably better to get OpenSSL from the source. Even though it is a tar.gz file, WinZip should be able to extract it from the gz and tar files.
Extract openssl-0.9.n.tar.gz, rename the folder to openssl, and move/copy and rename the root folder (i.e. has apps, bugs, certs, etc. in it) to ..\httpd-2.2.n\srclib\openssl.
Download zlib 1.2.3 (mod_deflate) from zlib.net. Extract zlib-1.2.3.tar.gz, extract the tar, copy/move subfolder ..\zlib-1.2.3-src\src\zlib\1.2.3\zlib-1.2.3 to ..\httpd-2.2.n\srclib\.. and rename it zlib.
Build Mod Deflate Using IDE
Open ..\httpd-2.2.n\srclib\zlib\projects\visualc6\zlib.dsw
Click Yes to All, to convert the example.dsp to the current Visual C++ project format.
Right click on "zlib" in Solution Explorer and select Properties
Click the Configuration Manager button
Set the "Active solution configuration:" to "LIB Release" or "LIB Debug". Click OK.
Select Build-> Build zlib. You'll get some annoying compiler errors. Go to (double click on the error message in the console) each offending line and remove it. Then rebuild it again.
Close the project and copy the generated file from
httpd-2.2.n\srclib\zlib\projects\visualc6\Win32_DLL_ASM_Debug\zlib1d.lib
or httpd-2.2.n\srclib\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib
to httpd-2.2.n\srclib\zlib\zlib.lib
Build Mod Deflate Using Command Line
Any takers?
Build OpenSSL Using Command Line
Start-> Programs-> Visual C++ 2005 Express Edition-> Visual Studio Tools-> Visual Studio 2005 Command Prompt
Or, start DOS, CD /D "C:\Program Files\Microsoft Visual Studio 8\VC\bin"
Run vcvars32.bat
CD /D "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2"
Run
CD to ..\httpd-2.2.n\srclib\openssl\.
Confirm awk is available by entering awk.
You should receive the feedback "Usage: awk [-f programfile | 'program'] [-Ffieldsep] [-v var=value] [files]"
Run
Code: |
perl Configure VC-WIN32
ms\do_masm
|
If ms\do_masm does not work try ms\do_ms or ms\do_nasm. If you still have problems, see the troubleshooting section in ..\srclib\openssl\INSTALL.W32 to hopefully, but not always resolve the issue.
Edit the files nt.mak & ntdll.mak in ..\httpd-2.2.n\srclib\openssl\ms\. Find and remove any /WX flag from the compiler options.
Run
Code: |
nmake -f ms\ntdll.mak
|
If you get "'nasmw' is not recognized as an internal or external command,", NASM is not in the system PATH. You should get a copy of OpenSSL built with no errors. Verify that the httpd-2.2.n\srclib\openssl\out32dll folder was generated
CD and run
Code: |
cd out32dll
..\ms\test
|
If all is well, the last output should present 'passed all tests'
If debugging, copy the folder httpd-2.2.0\srclib\openssl\out32dll to httpd-2.2.0\srclib\openssl\out32dll.dbg. Otherwise, do nothing since a Release will use OUT32DLL.
Patch Apache 2.2.3, ignore if Apache 2.2.4 or later
Follow the Apache 2.2.3 Patch instructions, download, and install/copy the patch files.
Using the same DOS window to build OpenSSL, CD to ..\apache_mod_ssl\httpd-2.2.n\.
If using VS.NET 2005 or Express to compile Apache 2.2.3, download cvtdsp.pl to ..\apache_mod_ssl\httpd-2.2.n\. and run 'perl cvtdsp.pl -2005'. Or, for VC++ 6.0, run 'perl cvtdsp.pl -6'. However, this is unnecessary.
Build Apache Using IDE
You're finally ready to build Apache!
Comment out (i.e. insert '#') all the following lines in ..\httpd-2.2.n\Makefile.win
Code: | !IFNDEF MAKEOPT
# Only default the behavior if MAKEOPT= is omitted
!IFDEF _NMAKE_VER
# Microsoft NMake options
MAKEOPT=-nologo
!ELSEIF "$(MAKE)" == "make"
# Borland make options? Not really supported (yet)
MAKEOPT=-s -N
!ENDIF
!ENDIF
|
found near line 135.
Open ..\httpd-2.2.n0\Apache.dsw. Click Yes To All at the convert project prompt.
Right click on "BuildBin" in Solution Explorer and select Properties
Click the Configuration Manager button
Set Active Solution Configuration: Release - while here you can also uncheck projects that you do not want to build.
Click Close
Select Configuration Properties, then CLICK NMake -
Build Command Line should read like (adjust INSTDIR as needed):
NMAKE /f makefile.win INSTDIR="\Progs\Apache2.2" LONG=Release _tryssl _tryzlib _dummy
Rebuild All Command Line should read like (adjust INSTDIR as needed):
NMAKE /f makefile.win INSTDIR="\Progs\Apache2.2" LONG=Release _tryssl _tryzlib _dummy
Change httpd.exe output to match INSTDIR - change as necessary
Click OK
Right click again on "BuildBin" in Solution Explorer
Select "Build"
The project will start building. If you get errors about "... could not do Version Info ..." then simply rerun the Build command. The first run has to build some dependencies that will be available for the 2nd run. The project may build with a few errors. If Makefile.win complains then open up ..\httpd-2.2.n\Makefile.win in a text editor and change the first char to a # and not a weird block char. If you get errors after the 2nd time then run the build a 3rd time to make sure. In the end you may always end up with some errors due to some module you didn't use that wants to be built but doesn't have to be.
Build Apache Using Command Line
Any takers?
Install Apache Using Visual C++ Express
Shutdown any running version of Apache and then exit the Apache monitor if it's on the taskbar.
Right click on "InstallBin" in Solution Explorer
Select Properties
Select Configuration Properties, then CLICK NMake -
Build Command Line - (adjust INSTDIR as needed)
Rebuild All Command Line - (adjust INSTDIR as needed)
Output changed to match INSTDIR - change as necessary
Click the Configuration Manager button
Set Active Solution Configuration: Release - while here you can also uncheck projects that you do not want to build
IF you use the Configuration Manager on BuildBin to set to Debug|Release it will adjust the InstallBin as well
Click Close and click OK
Right click again on "InstallBin" in Solution Explorer
Select "Build"
The project should build with no errors. If makefile.win complains about : then open up httpd-2.2.n\Makefile.win in a text editor and fix the first char to be a # and not a weird block char. If you get errors run the build a 2nd time. If you still have errors run the build a 3rd time. If that fails look at the error log to see if you can determine the source. This step should end with no errors.
Close the project.
You should now have a complete C:\..\Apache2.n folder with your new compilation. You may want to use the sample httpd.conf file in httpd-2.2.n\docs\conf\httpd-win.conf
If you want openssl.exe to work you must copy the file httpd-2.2.n\srclib\openssl\out32dll\openssl.exe.manifest to folder ..\Apache2.n\bin
You will want to add the following to avoid having to install Dot NET framework 2.0 on new machines. In your ..\Apache2.n\bin folder, create a file named: Microsoft.VC80.CRT.manifest :with the following contents:
Code: |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Copyright © 1981-2001 Microsoft Corporation -->
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<noInheritable/>
<assemblyIdentity
type="win32"
name="Microsoft.VC80.CRT"
version="8.0.50608.0"
processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b"
/>
<file name="msvcr80.dll"/>
<file name="msvcp80.dll"/>
<file name="msvcm80.dll"/>
</assembly>
|
rbeede wrote: |
Copy the file MSVCR80.DLL to your ..\Apache21\bin folder
|
or ..\Apache2.2\bin folder. I never found the MSVCR80.DLL rbeede mentioned. So, I used a PC with the Dot NET framework 2.0 intalled. Just the manifest, Microsoft.VC80.CRT.manifest, was needed.
Refer to http://www.devside.net/web/server/windows/apache regarding installation of the Apache2 service with mod_ssl. However, "httpd -D SSL -k install" is not needed if you enable it via directive. See "Configure Apache to Use Mod SSL" below.
Install Apache Using Command Line
Any takers?
Installing OpenSSL as a Utility
If you'd like to install OpenSSL to generate certificates, refer to Building OpenSSL 0.9.8b for Windows 2000/XP. Also, refer to the part about 'Installation' in ..\srclib\INSTALL.W32.
Skip the download, config, and build instructions since you completed them during the Apace mod_ssl build and install.
Using the same DOS window to build OpenSSL, CD to ..\apache_mod_ssl\httpd-2.2.n\.
cd /d C:\Workspace\apache_mod_ssl\httpd-2.2.n\srclib\openssl
Change #INSTALLTOP=\usr\local\ssl to INSTALLTOP=\Progs\Openssl in ntdll.mak
Note: I use C:\Progs and C:\Workspace as a standard places for development software and workspace. This convention is followed throughout these instructions. If you prefer, rename it or remove it.
Code: |
nmake -f ms\ntdll.mak install
|
Exit DOS
Add OpenSSL bin to PATH and create OPENSSL_CONF variable
Use Start-> Settings-> Control Panel-> System-> Advanced-> Environment Variables-> System variables-> Path
Insert "C:\Progs\Openssl\bin;" in the front of the path variable
Create a new system environment variable OPENSSL_CONF=c:\Progs\Openssl\openssl.cnf
Create a Self Signed Certificate
If you need a Treasury Certificate for the TCSnet servers, skip to the next
section.
Refer to http://www.devside.net/web/config/ssl-key-pair about SSL Private/Public Key-Pair Setup for Apache 2.0.
To be able to accept 'https://' requests, a private/public key-pair for Apache 2.0 w/ mod_ssl is created and stored in the proper location(s). Before proceeding - the location of executable 'openssl.exe' must be in the PATH, or the command line must be under the directory containing this file. Make sure that 'openssl.exe' can find its configuration file 'openssl.cnf' by either creating a OPENSSL_CONF system environment variable or using the "-config" parameter. Visit the OpenSSL user group for more details.
Example:
OPENSSL_CONF=c:\Progs\Openssl\openssl.cnf
openssl req -new -config c:\Progs\Openssl\openssl.cnf -out server.csr
To create a self-signed private/public 1024 bit key-pair that will be valid for 10 years (3650 days)...
* Open a DOS window
* cd to a working/temporary directory
> openssl req -new -out server.csr
This creates a certificate signing request (CSR) file (server.csr) and private key (privkey.pem). If openssl.cnf is not fully configured, you will be asked several pieces of information.
PEM passphrase:
Country: whatever fits your hierarchy
State: whatever fits your hierarchy
Locality: whatever fits your hierarchy
Organization: whatever fits your hierarchy
Organizational Unit: whatever fits your hierarchy
Common Name: typically the URL of the workstation or server
Email Address:
Challenge password: I used the PEM passphrase.
Optional Company Name: could be the name of a company or contract
> openssl rsa -in privkey.pem -out server.key
Provide the passphrase. This removes the passphrase from private key (privkey.pem), creating server.key.
> openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650
Creates a self-signed certificate file server.crt (public key).
> move server.crt C:\Progs\Apache2.2\conf\
This .crt is the public key (also know as the 'Certificate') file referred to in httpd-ssl.conf.
> move server.key C:\Progs\Apache2.2\conf\
This .key file is the private key file referred to in httpd-ssl.conf.
> del .rnd
.rnd contains entropy information, could be used to re-create keys
> del privkey.pem
> del server.csr
Keep server.csr if you plan on self-signing more keys and you want the authority to match up exactly.
Configure Apache to Use Mod SSL
In ..\Apache2.2\conf\httpd.conf, uncomment the following directives:
Code: |
...
LoadModule ssl_module modules/mod_ssl.so
...
Include conf/extra/httpd-ssl.conf
...
|
Run Apache and test access to https://localhost/
Hint: enable one directive at a time while stopping and starting the server at the command line. If you start and stop Apache via services you will not get any meaningful error statements. Also, you may need to modify directives in ..\Apache2.2\conf\extra\\httpd-ssl.conf. Visit "Using Apache with Microsoft Windows" for more information about configuring and running Apache.
Helpful Sites:
How to build Apache 2.2.0 on Windows XP provides a good high level perspective.
Visit Apache.org for a general perspective about compiling and using Apache with Microsoft Windows.
Visit the DeveloperSide.NET Forum Index-> Building a Web Server, for Windows 2000/XP for a review of early adopter trials and tribulations.
Building Apache 2.2.3 or 2.0.59 for Windows 2000/XP is primarily geared for version 2.0.nn but still helpful.
And this lounge is not too shabby a place for Apache aficionados.
For a brief understanding of why most web sites do not risk providing binaries of Apache with OpenSSL visit ssleay. Even though this is nearly ten years old it is still probably relevant. |
|
Back to top |
|
ali_fareed
Joined: 04 Jul 2006 Posts: 61 Location: Bahrain
|
Posted: Sun 10 Sep '06 16:14 Post subject: |
|
|
I just wanted to add for people who are using cygwin's awk the awk in the bin folder is a symlink to gawk.exe you should delete awk and rename gawk to awk.exe or copy it if you dont you will get an error while compiling apache |
|
Back to top |
|
PipoDeClown
Joined: 20 Dec 2005 Posts: 77
|
Posted: Fri 29 Sep '06 18:21 Post subject: |
|
|
Thank you, this howto works great.
Only thing is that the manual compiling of OpenSSL didnt produce some debug files, so InstallBin complained about not finding those. It completed nevertheless. |
|
Back to top |
|
gthornejr
Joined: 02 Feb 2007 Posts: 2
|
Posted: Fri 02 Feb '07 1:09 Post subject: How to Build Apache Mod SSL 2.2.n Using Visual C++ Express |
|
|
I am using Visual Studio 2005 Pro to build Apache 2.2.4, and I still needed to download and run the cvtdsp.pl -2005 patch mentioned above. Without using this patch, I got the error described in mrtechguy's post "Syntax of RC.exe being passed incorrectly"
Thanks,
Gary Thorne |
|
Back to top |
|
cartoper
Joined: 01 Mar 2007 Posts: 5
|
Posted: Sun 11 Mar '07 4:02 Post subject: fatal error RC1107: invalid usage; |
|
|
I have downloaded cvtdsp.pl from:
http://svn.apache.org/repos/asf/apr/apr/trunk/build/cvtdsp.pl
Than I ran it in the root of the 2.2.4 source. It clams to have updated the project files, but when I go to compile, I am still getting errors. When I look at the detailed logs, my rc files still have too many quotes:
Creating command line "rc.exe /d "_DEBUG" /d "BIN_NAME="libhttpd.dll"" /d "LONG_NAME="Apache HTTP Server Core"" /d "_VC80_UPGRADE=0x0600" /l 0x409 /I "build\win32" /I "./include" /I "./srclib/apr/include" /fo"Debug/libhttpd.res" ".\build\win32\httpd.rc""
If my understanding of the problem is correct, rather then having:
/d "BIN_NAME="libhttpd.dll""
it should simply be
/d BIN_NAME="libhttpd.dll"
Anyone have any thoughts on what I am doing wrong? |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Sun 11 Mar '07 7:43 Post subject: |
|
|
cvtdsp.pl presumes that you run it first to convert the existing (VC6) .dsp files,
then you open Apache.dsw with Visual Studio 2005 (VS8) which converts all the .dsp files to .vcproj files.
If you run cvtdsp.pl after you have already run VS8, it won't help.
You can delete your Apache.sln and all the .vcproj files, then open Apache.dsw and let VS8 upgrade all the projects again.
Another way is to install the GNUWin sed editor and use this sed command to convert your existing .vcproj files Quote: | FOR /R %a IN (*.vcproj) DO sed -i "s_\([^\\]\)"_\1_g" %a | .
Either way, make sure that you do not have Apache open in Visual Studio when you run the conversion.
Hope this helps,
-tom- |
|
Back to top |
|
vihila
Joined: 25 Dec 2007 Posts: 1
|
Posted: Tue 25 Dec '07 18:54 Post subject: |
|
|
Thanks very much for providing these instructions! They work great. It took me a while to realize that the Platform SDK "setenv" command needs to be run in addition to the Visual C++ Express "vsvars32" command before compiling.
In regards to building mod_deflate (zlib) from the command line, this worked for me (requires MASM32)
Code: | C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\SetEnv.Cmd
cd /d C:\build\httpd-2.2.x\srclib\zlib
ML /coff /Zi /c contrib\masm686\match.asm
NMAKE -f win32\Makefile.msc LOC="-D_CRT_SECURE_NO_DEPRECATE /wd4996 -DASMV" OBJA="match.obj"
example.exe
|
... there might be a way to do it using NASM, but I haven't figured it out yet. I prefer your method of using the visual IDE better anyway.
And to compile Apache from the command line, this works for me quite well (after making the modifications to Makefile.win that you suggested):
Code: | C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\SetEnv.Cmd
cd /d C:\build\httpd-2.2.x
nmake /f Makefile.win SERVERNAME="localhost" PORT=80 INSTDIR="C:\www\Apache22" installr
|
|
|
Back to top |
|
|
|
|
|
|