在Windows平台VC2010编译64位OpenSSL 1.0.1j动态库

下载最新的OpenSSL源代码。目前的最新版本是1.0.1j 。下载地址:https://www.openssl.org/source/openssl-1.0.1j.tar.gz。下载到本地并解压到 D:\dev\openssl-1.0.1j。解压后可以看到如下的文件:

INSTALL.DJGPP | DOS系统
INSTALL.MacOS | 苹果Mac OS X
INSTALL.NW | Novell NetWare
INSTALL.OS2 | IBM OS2
INSTALL.VMS | VMS
INSTALL.W32 | Windows 32位
INSTALL.W64 | Windows 64位
INSTALL.WCE | Windows CE

因为OpenSSL是支持多平台的开源SSL库。以上文件就是各种操作系统的具体安装编译方法文档。

打开 “Visual Studio x64 兼容工具命令提示(2010)”会自动打开一个带VC编译环境的命令行。进入D:\dev\openssl-1.0.1j 目录运行

D:\dev\openssl-1.0.1j>perl Configure VC-WIN64A
D:\dev\openssl-1.0.1j>ms\do_win64a.bat
D:\dev\openssl-1.0.1j>nmake -f ms\ntdll.mak
D:\dev\openssl-1.0.1j>cd out32dll
D:\dev\openssl-1.0.1j>..\ms\test.bat

如果你没有perl的运行环境,请到http://www.activestate.com/activeperl/downloads去下载。

do_win64a.bat这个批处理使用perl来生成我们后续编辑链接所需要的mak和def文件。最后用nmake来编译链接。等待大概5分钟编译了848个c文件之后。生成的文件放在out32dll目录。最后的test.bat可以运行所有的测试。

如果需要编译Intel Itanium 64bit构架(一般在Windows Server上使用的CPU构架)命令变为以下,但是这个一般都用得很少

D:\dev\openssl-1.0.1j>perl Configure VC-WIN64I
D:\dev\openssl-1.0.1j>ms\do_win64i.bat
D:\dev\openssl-1.0.1j>nmake -f ms\ntdll.mak
D:\dev\openssl-1.0.1j>cd out32dll
D:\dev\openssl-1.0.1j>..\ms\test.bat

如果需要编译常见的Win32(x86),命令如下

D:\dev\openssl-1.0.1j>perl Configure VC-WIN32
D:\dev\openssl-1.0.1j>ms\do_ms.bat
D:\dev\openssl-1.0.1j>nmake -f ms\ntdll.mak
D:\dev\openssl-1.0.1j>cd out32dll
D:\dev\openssl-1.0.1j>..\ms\test.bat

Apache 2.4的httpd.conf模版

可以基于此文件按照你的需求进行修改。此配置是WampServer的默认配置加上了我自己的一些虚拟主机配置。一共176行。

ServerSignature On
ServerTokens Full
ServerRoot "D:/wamp/bin/apache/apache2.4.9"
Define APACHE24 Apache2.4
Listen 0.0.0.0:80
Listen [::0]:80
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cache_module modules/mod_cache.so
LoadModule cache_disk_module modules/mod_cache_disk.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule php5_module "D:/wamp/bin/php/php5.5.12/php5apache2_4.dll"
#PHPIniDir D:/wamp/bin/php/php5.5.12
ServerAdmin admin@tunps.com
ServerName localhost:80
HostnameLookups Off
DocumentRoot "D:/wamp/www/"
<Directory />
    AllowOverride none
    Require all denied
</Directory>
<Directory "D:/wamp/www/">
    Options Indexes FollowSymLinks
    AllowOverride all
    Require local
</Directory>
<IfModule dir_module>
    DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>
<Files ".ht*">
    Require all denied
</Files>
ErrorLog "D:/wamp/logs/apache_error.log"
LogLevel warn
<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    CustomLog "D:/wamp/logs/access.log" combined
</IfModule>
<IfModule alias_module>
    ScriptAlias /cgi-bin/ "D:/wamp/bin/apache/apache2.4.9/cgi-bin/"
</IfModule>
<Directory "D:/wamp/bin/apache/apache2.4.9/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>
<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-httpd-php .php
</IfModule>
#alias
Alias /phpmyadmin "D:/wamp/apps/phpmyadmin4.1.14/"
<Directory "D:/wamp/apps/phpmyadmin4.1.14/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    <IfDefine APACHE24>
        Require local
    </IfDefine>
    <IfDefine !APACHE24>
        Order Deny,Allow
        Deny from all
        Allow from localhost ::1 127.0.0.1
    </IfDefine>
    php_admin_value upload_max_filesize 128M
    php_admin_value post_max_size 128M
    php_admin_value max_execution_time 360
    php_admin_value max_input_time 360
</Directory>
Alias /phpsysinfo "D:/wamp/apps/phpsysinfo3.1.12/"
<Directory "D:/wamp/apps/phpsysinfo3.1.12/">
    Options Indexes FollowSymLinks
    AllowOverride all
  <IfDefine APACHE24>
    Require local
  </IfDefine>
  <IfDefine !APACHE24>
    Order Deny,Allow
      Deny from all
      Allow from localhost ::1 127.0.0.1
    </IfDefine>
</Directory>
Alias /sqlbuddy "D:/wamp/apps/sqlbuddy1.3.3/"
<Directory "D:/wamp/apps/sqlbuddy1.3.3/">
    Options Indexes FollowSymLinks
    AllowOverride all
  <IfDefine APACHE24>
    Require local
  </IfDefine>
  <IfDefine !APACHE24>
    Order Deny,Allow
      Deny from all
      Allow from localhost ::1 127.0.0.1
    </IfDefine>
</Directory>
Alias /webgrind "D:/wamp/apps/webgrind1.0/"
<Directory "D:/wamp/apps/webgrind1.0/">
    Options Indexes FollowSymLinks
    AllowOverride all
  <IfDefine APACHE24>
    Require local
  </IfDefine>
  <IfDefine !APACHE24>
    Order Deny,Allow
      Deny from all
      Allow from localhost ::1 127.0.0.1
    </IfDefine>
</Directory>
#virtualhost
<VirtualHost *:80>
    <Directory "d:/www/pagedown">
        Options Indexes FollowSymLinks
        AllowOverride all
        Require all granted
    </Directory>
    ServerAdmin me@tunps.com
    DocumentRoot "d:/www/pagedown"
    ServerName pagedown
    ServerAlias pagedown
    ErrorLog "logs/pagedown-error.log"
    CustomLog "logs/pagedown-access.log" common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin me@tunps.com
    <Directory "d:/www/diary">
        Options Indexes FollowSymLinks
        AllowOverride all
        Require all granted
    </Directory>
    DocumentRoot "d:/www/diary"
    ServerName diary
    ServerAlias diary
    ErrorLog "logs/diary-error.log"
    CustomLog "logs/diary-access.log" common
</VirtualHost>