jekeyhui99 发表于 2018-10-21 20:26:59

windows下面配置apache+https

<p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);">在Apache里配一个&lt;VirtualHost *:6044&gt;,然后针对这个6044设置https,https可反向代理映射到http地址,但http不可反向代理映射到https地址。</span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;">需要修改<span lang="EN-US" style="line-height: 1.8;">httpd.conf&nbsp;、httpd-vhosts.conf两个文件</span></span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;">1、修改conf/httpd.conf&nbsp;取消以下注释,使appache启动时调用ssl服务:</span></span></p><div class="cnblogs_code" style="margin-top: 5px; margin-bottom: 5px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot; !important; font-size: 12px !important;"><pre style="white-space: pre-wrap; font-family: &quot;Courier New&quot; !important;">#LoadModule ssl_module modules/<span style="line-height: 1.8;">mod_ssl.so <span style="line-height: 1.8;">(去掉前面的‘#’号)</span>
#Include conf</span>/extra/httpd-ssl.conf      <span style="line-height: 1.8;">(去掉前面的‘#’号)</span></pre></div><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;">2、生成证书</span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;">win+R:cmd进入命令行,<span style="line-height: 1.8;"><span lang="EN-US" style="line-height: 1.8; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;">进入apache安装目录的bin文件&nbsp;</span></span></span><span style="line-height: 1.8; color: rgb(51, 153, 102);"><strong>cd C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin</strong></span></span></span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;">设置OPENSSL_CONFIG配置,执行命令&nbsp;<span style="line-height: 1.8; color: rgb(51, 153, 102);"><strong>set OPENSSL_CONF=..\conf\openssl.cnf</strong></span></span></span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;">(a)生成服务端的key文件</span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;">  执行命令:<strong><span style="line-height: 1.8; color: rgb(51, 153, 102);">openssl genrsa -out server.key 1024</span></strong></span></span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在bin目录中生成server.key文件</span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;">(b)生成签署申请</span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 执行命令:<span style="line-height: 1.8; color: rgb(51, 153, 102);"><strong>openssl req -new -out server.csr -key server.key</strong></span></span></span></span></span></span></p><p style="margin: 10px auto 10px 30px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><strong>&nbsp;&nbsp;</strong><span style="line-height: 1.8; color: rgb(0, 0, 0);">在bin目录中生成server.csr文件,在执行以上命令时会提示输入相关信息,其中&nbsp;Common Name &lt;eg,YOUR name&gt;[]&nbsp;需要与配置文件中的ServerName一致,否则apache启动时将会报错。</span></span></span></span><span lang="EN-US" style="line-height: 1.8; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);">&nbsp;&nbsp;<strong>&nbsp;&nbsp;&nbsp;</strong>&nbsp;&nbsp;&nbsp;<br></span></span></span></span></span></span></span></p><div class="cnblogs_code" style="margin-top: 5px; margin-bottom: 5px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot; !important; font-size: 12px !important;"><div class="cnblogs_code_toolbar" style="margin-top: 5px;"><span class="cnblogs_code_copy" style="padding-right: 5px; line-height: 1.8;"><a title="复制代码" style="color: rgb(0, 0, 0); border: none !important;"><img src="https://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="max-width: 900px; height: auto;"></a></span></div><pre style="white-space: pre-wrap; font-family: &quot;Courier New&quot; !important;">Country Name&lt;<span style="line-height: 1.8; color: rgb(128, 0, 128);">2</span> letter code&gt;<span style="line-height: 1.8;"> : cn
State or Province Name </span>&lt;full name&gt; : jangsu
Locality Name</span>&lt;eg , city&gt;<span style="line-height: 1.8;">[] : nanjing
Oraganization Name </span>&lt;eg,company&gt;<span style="line-height: 1.8;"> : epms.cwp
Organizational Unit Name </span>&lt;eg,section&gt;<span style="line-height: 1.8;"> [] epms
Common Name</span>&lt;eg, YOUR name&gt;<span style="line-height: 1.8;">[]:ServerName
Email Address []: ..................................
..................................................................................
A challenge password []: (可不输入)</span></pre><div class="cnblogs_code_toolbar" style="margin-top: 5px;"><span class="cnblogs_code_copy" style="padding-right: 5px; line-height: 1.8;"><a title="复制代码" style="color: rgb(0, 0, 0); border: none !important;"><img src="https://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="max-width: 900px; height: auto;"></a></span></div></div><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;">&nbsp;<span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;">(c)生成CA的key文件</span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;执行命令:</span></span><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 204, 0);"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><strong>openssl genrsa -out ca.key 1024</strong></span></span></span></span></span></span></span></span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 204, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="line-height: 1.8; color: rgb(51, 51, 0);">&nbsp;在目录bin下生成ca.key文件</span></span></span></span></span></span></span></span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 204, 0);"><span style="line-height: 1.8; color: rgb(51, 51, 0);">(d)&nbsp;生成CA自签署证书</span></span></span></span></span></span></span></span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 204, 0);"><span style="line-height: 1.8; color: rgb(51, 51, 0);"><span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;">   执行命令:<span style="line-height: 1.8; color: rgb(51, 153, 102);"><strong>openssl req -new -x509 -days 365 -key ca.key -out ca.crt</strong></span></span></span></span></span></span></span></span></span></span></span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 204, 0);"><span style="line-height: 1.8; color: rgb(51, 51, 0);">&nbsp;&nbsp;&nbsp;<span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;"> &nbsp; 在目录bin下生成ca.crt文件</span></span></span></span></span></span></span></span></span></span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 204, 0);"><span style="line-height: 1.8; color: rgb(51, 51, 0);"><span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;">(e)生成CA的服务器签署证书</span></span></span></span></span></span></span></span></span></span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span style="line-height: 1.8; color: rgb(51, 204, 0);"><span style="line-height: 1.8; color: rgb(51, 51, 0);"><span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;"> <span style="line-height: 1.8;"><span style="line-height: 1.8;">执行命令:<span style="line-height: 1.8; color: rgb(51, 204, 0);"><strong><span style="line-height: 1.8; color: rgb(51, 153, 102);">openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key</span> </strong></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span style="line-height: 1.8; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;"><span style="line-height: 1.8;"><span style="line-height: 1.8;"> 在这里</span></span></span></span></span></span><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;"><span style="line-height: 1.8;"><span style="line-height: 1.8;">报错了,按照网上的说法新建相</span></span></span></span></span></span><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;"><span style="line-height: 1.8;"><span style="line-height: 1.8;">应的文</span></span></span></span></span></span><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;"><span style="line-height: 1.8;"><span style="line-height: 1.8;">件夹,</span></span></span></span></span></span><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;"><span style="line-height: 1.8;"><span style="line-height: 1.8;"><span lang="EN-US" style="line-height: 1.8; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8;">再执行一次就可以了</span></span></span></span></span></span>。</span></span></span></span></span></span></span></p><div class="cnblogs_code" style="margin-top: 5px; margin-bottom: 5px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot; !important; font-size: 12px !important;"><pre style="white-space: pre-wrap; font-family: &quot;Courier New&quot; !important;">在bin下新建demoCA文件夹                 =&gt;bin/<span style="line-height: 1.8;">demoCA
在demoCA下新建index.txt                 </span>=&gt;bin/demoCA/<span style="line-height: 1.8;">index.txt
在demoCA下新建serial.txt,其内容为01,重命名删除.txt   </span>=&gt;bin/demoCA/<span style="line-height: 1.8;">serial
在demoCA下新建newcert文件夹               </span>=&gt;sbin/demoCA/newcerts</pre></div><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8; color: rgb(51, 153, 102);"><span style="line-height: 1.8;"><span style="line-height: 1.8; color: rgb(51, 204, 0);"><span style="line-height: 1.8; color: rgb(51, 51, 0);"><span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;"><span style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8; color: rgb(51, 204, 0);"> <span style="line-height: 1.8; color: rgb(0, 0, 0);">3</span></span></span></span></span></span></span></span></span></span></span></span><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;"><span style="line-height: 1.8;"><span style="line-height: 1.8;">、<span lang="EN-US" style="line-height: 1.8; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8;"><span lang="EN-US" style="line-height: 1.8; font-size: 10.5pt;"><span style="line-height: 1.8; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span lang="EN-US" style="line-height: 1.8; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8;">修改httpd-ssl.conf文件</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;"><span style="line-height: 1.8;"><span style="line-height: 1.8;"><span lang="EN-US" style="line-height: 1.8; font-size: 10.5pt;"><span style="line-height: 1.8; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;">(a)<span lang="EN-US" style="line-height: 1.8; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8;">根据需要修改httpd-ssl.conf的默认端口号“443”,<span lang="EN-US" style="line-height: 1.8; font-size: 10.5pt;"><span style="line-height: 1.8; font-size: 10.5pt;"><span lang="EN-US" style="line-height: 1.8;">这里将所有的443修改为“6044”,同时修改ServerName。</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><div class="cnblogs_code" style="margin-top: 5px; margin-bottom: 5px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot; !important; font-size: 12px !important;"><pre style="white-space: pre-wrap; font-family: &quot;Courier New&quot; !important;">&lt;VirtualHost _default_:<span style="line-height: 1.8; color: rgb(128, 0, 128);">6044</span>&gt;<span style="line-height: 1.8;">         
ServerName........................:</span><span style="line-height: 1.8; color: rgb(128, 0, 128);">6044</span></pre></div><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;">&nbsp;(b) 修改相关证书路径,<span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;">把路径设置为conf下的key目录,把生成的证书放进这个目录</span></span></p><div class="cnblogs_code" style="margin-top: 5px; margin-bottom: 5px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot; !important; font-size: 12px !important;"><pre style="white-space: pre-wrap; font-family: &quot;Courier New&quot; !important;">SSLCertificateFile    xxx/conf/key/<span style="line-height: 1.8;">server.crt    (服务器证书的位置)
SSLCertificateKeyFile    xxx</span>/conf/key/<span style="line-height: 1.8;">server.key (服务器私钥的位置)
SSLCACertificateFile    xxx</span>/key/conf/<span style="line-height: 1.8;">ca.crt      (CA根证书的位置,进行客户端验证时需要)
</span></pre></div><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;">(c) 取消注释</p><div class="cnblogs_code" style="margin-top: 5px; margin-bottom: 5px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot; !important; font-size: 12px !important;"><pre style="white-space: pre-wrap; font-family: &quot;Courier New&quot; !important;"><span style="line-height: 1.8;">#SSLVerifyClient require               (去掉前面的‘#’号,进行客户端验证时需要)
#SSLVerifyDepth</span><span style="line-height: 1.8; color: rgb(128, 0, 128);">1</span>                     (去掉前面的‘#’号,把10改为1,进行客户端验证时需要)</pre></div><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;">(d) 选择性修改,如果在运行时报错,可修改SSLSessionCache再执行</p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;">修改前:</p><div class="cnblogs_code" style="margin-top: 5px; margin-bottom: 5px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot; !important; font-size: 12px !important;"><pre style="white-space: pre-wrap; font-family: &quot;Courier New&quot; !important;">#SSLSessionCache         <span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">dbm:C:/Program Files (x86)/Apache Software Foundation/Apache2.2/logs/ssl_scache</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8;">
SSLSessionCache      </span><span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">shmcb:C:/Program Files (x86)/Apache Software Foundation/Apache2.2/logs/ssl_scache(512000)</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8;">
SSLSessionCacheTimeout</span><span style="line-height: 1.8; color: rgb(128, 0, 128);">300</span></pre></div><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;">修改后:</p><div class="cnblogs_code" style="margin-top: 5px; margin-bottom: 5px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot; !important; font-size: 12px !important;"><pre style="white-space: pre-wrap; font-family: &quot;Courier New&quot; !important;">SSLSessionCache         <span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">dbm:C:/Program Files (x86)/Apache Software Foundation/Apache2.2/logs/ssl_scache</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8;">
#SSLSessionCache      </span><span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">shmcb:C:/Program Files (x86)/Apache Software Foundation/Apache2.2/logs/ssl_scache(512000)</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8;">
SSLSessionCacheTimeout</span><span style="line-height: 1.8; color: rgb(128, 0, 128);">300</span></pre></div><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;">4、重启apache,执行两个命令<span style="line-height: 1.8; color: rgb(51, 153, 102);"><strong>net stop Apache2.2</strong>和<strong>net start Apache2.2,</strong><span style="line-height: 1.8; color: rgb(0, 0, 0);">浏览器中输入https//..............:6044页面会提示 It works!</span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;">5、修改httpd-vhosts.conf 设置反向代理,重<span style="line-height: 1.8; color: rgb(0, 0, 0);">启apache,浏览器中输入https//..............:6044页面会跳转到相应的代理页面(注意DocumentRoot路径要存在)</span></p><div class="cnblogs_code" style="margin-top: 5px; margin-bottom: 5px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot; !important; font-size: 12px !important;"><div class="cnblogs_code_toolbar" style="margin-top: 5px;"><span class="cnblogs_code_copy" style="padding-right: 5px; line-height: 1.8;"><a title="复制代码" style="color: rgb(0, 0, 0); border: none !important;"><img src="https://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="max-width: 900px; height: auto;"></a></span></div><pre style="white-space: pre-wrap; font-family: &quot;Courier New&quot; !important;">NameVirtualHost *:<span style="line-height: 1.8; color: rgb(128, 0, 128);">6044</span><span style="line-height: 1.8;">

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section </span><span style="line-height: 1.8; color: rgb(0, 0, 255);">is</span> used <span style="line-height: 1.8; color: rgb(0, 0, 255);">for</span> all requests that <span style="line-height: 1.8; color: rgb(0, 0, 255);">do</span><span style="line-height: 1.8;"> not
# match a ServerName or ServerAlias </span><span style="line-height: 1.8; color: rgb(0, 0, 255);">in</span> any &lt;VirtualHost&gt;<span style="line-height: 1.8;"> block.
#
</span>&lt;VirtualHost *:<span style="line-height: 1.8; color: rgb(128, 0, 128);">6044</span>&gt;<span style="line-height: 1.8;">
   DocumentRoot </span><span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">C:/Program Files (x86)/Apache Software Foundation/Apache2.2/docs/</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8;">
   ServerName ......</span>:<span style="line-height: 1.8; color: rgb(128, 0, 128);">6044</span><span style="line-height: 1.8;">   
   SSLEngine on
   SSLProxyEngine on
   SSLCertificateFile </span><span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/key/server.crt</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8;">
   SSLCertificateKeyFile </span><span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/key/server.key</span><span style="line-height: 1.8; color: rgb(128, 0, 0);">"</span><span style="line-height: 1.8;">
   ProxyRequests Off   
</span>&lt;Proxy *&gt;<span style="line-height: 1.8;">
Order deny,allow
Allow </span><span style="line-height: 1.8; color: rgb(0, 0, 255);">from</span><span style="line-height: 1.8;"> all
</span>&lt;/Proxy&gt;<span style="line-height: 1.8;">
   ProxyPass </span>/ http:<span style="line-height: 1.8; color: rgb(0, 128, 0);">//......</span><span style="line-height: 1.8; color: rgb(0, 128, 0);">/</span>
   ProxyPassReverse / http:<span style="line-height: 1.8; color: rgb(0, 128, 0);">//......</span><span style="line-height: 1.8; color: rgb(0, 128, 0);">/</span>
&lt;/VirtualHost&gt;</pre><div class="cnblogs_code_toolbar" style="margin-top: 5px;"><span class="cnblogs_code_copy" style="padding-right: 5px; line-height: 1.8;"><a title="复制代码" style="color: rgb(0, 0, 0); border: none !important;"><img src="https://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="max-width: 900px; height: auto;"></a></span></div></div><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;">6、假如遇到apache无法启动的时候,可以选我的电脑-》管理-》事件检查器-》应用程序日志,打开apache的错误报告,会有提示哪里出错了,一般都可以找到原因,</span></span></span></span></p><p style="margin: 10px auto; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-size: 14px;"><span lang="EN-US" style="line-height: 1.8; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span lang="EN-US" style="line-height: 1.8;"><span style="line-height: 1.8;"><span style="line-height: 1.8; white-space: pre;"> 可以启动,但无法映射到对应页面,可以命令中输入httpd 会提示相应的错误。</span></span></span></span></p><p></p>
页: [1]
查看完整版本: windows下面配置apache+https