Windows下配置Apache的SSL服务.docx

上传人:b****8 文档编号:30285925 上传时间:2023-08-13 格式:DOCX 页数:11 大小:795.37KB
下载 相关 举报
Windows下配置Apache的SSL服务.docx_第1页
第1页 / 共11页
Windows下配置Apache的SSL服务.docx_第2页
第2页 / 共11页
Windows下配置Apache的SSL服务.docx_第3页
第3页 / 共11页
Windows下配置Apache的SSL服务.docx_第4页
第4页 / 共11页
Windows下配置Apache的SSL服务.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

Windows下配置Apache的SSL服务.docx

《Windows下配置Apache的SSL服务.docx》由会员分享,可在线阅读,更多相关《Windows下配置Apache的SSL服务.docx(11页珍藏版)》请在冰豆网上搜索。

Windows下配置Apache的SSL服务.docx

Windows下配置Apache的SSL服务

Windows下配置Apache的SSL服务

到Apache的网站上下载包含有SSL服务的安装包。

如果你已经安装过了Apache,在安装含有SSL服务的Apache服务器之前需要卸载已经安装过的。

到控制面板里面直接卸载就可以了。

注意:

Apache在卸载的时候不会删除httpd.conf这个配置文件和htdocs文件夹下面的内容。

如果你确实不需要,你需要手工删除。

在Windows的环境下面安装含有SSL的Apache和不含有Apache的方法和过程一致。

这里关键说安装以后的服务配置。

httpd.conf文件,如果需要Apache服务器支持SSL,这里需要载入几个模块。

去掉下面两行之前的#符号

LoadModulessl_modulemodules/mod_ssl.so

Includeconf/extra/httpd-ssl.conf

LoadModulessl_modulemodules/mod_ssl.so的作用是载入SSL模块

Includeconf/extra/httpd-ssl.conf的作用是告诉Apache的SSL模块到那里去找配置文件

重新启动服务器,测试一下看有没有什么问题。

显然在重新启动服务器的时候报了一个错误,说服务器无法正常启动。

这时候我们可以看看日志文件了。

[FriAug1515:

33:

082008][notice]Parent:

Receivedrestartsignal--Restartingtheserver.

[FriAug1515:

33:

082008][notice]Child740:

Exiteventsignaled.Childprocessisending.

Syntaxerroronline99ofD:

/Dkits/Apache2.2/conf/extra/httpd-ssl.conf:

SSLCertificateFile:

file'D:

/Dkits/Apache2.2/conf/server.crt'doesnotexistorisempty

[FriAug1515:

33:

082008][warn](OS995)TheI/Ooperationhasbeenabortedbecauseofeitherathreadexitoranapplicationrequest.:

winnt_accept:

AsynchronousAcceptExfailed.

[FriAug1515:

33:

092008][notice]Child740:

Releasedthestartmutex

[FriAug1515:

33:

102008][notice]Child740:

Allworkerthreadshaveexited.

[FriAug1515:

33:

102008][notice]Child740:

Childprocessisexiting

上面说在D:

/Dkits/Apache2.2/conf/server.crt路径下找不到server.crt这个文件。

那么,这个文件在那里呢?

这个文件需要我们用openssl这个程序来生成的。

生成这个server.crt文件需要2个文件,一个是openssl.exe另一个是f。

一般来说openssl.exe在你Apache的安装路径下的bin文件夹里面,f在Apache安装路径下的conf文件里面。

找不到?

如果找不到就用windows的查找搜索一下了。

这个时候你需要将openssl.exe和f放在同一个文件夹里面。

一般的需要将找到的f文件拷贝到bin文件里面。

用openssl生成KEY

生成自签名文件

首先生成csr和pem文件。

命令是:

opensslreq-configf-new-outserver.csr-keyoutserver.pem

运行结果如下:

D:

\Dkits\Apache2.2\bin>opensslreq-configf-new-outserver.csr-keyoutserver.pem

Loading'screen'intorandomstate-done

Generatinga1024bitRSAprivatekey

.........++++++

.........++++++

writingnewprivatekeyto'server.pem'

EnterPEMpassphrase:

Verifying-EnterPEMpassphrase:

-----

Youareabouttobeaskedtoenterinformationthatwillbeincorporated

intoyourcertificaterequest.

WhatyouareabouttoenteriswhatiscalledaDistinguishedNameoraDN.

Therearequiteafewfieldsbutyoucanleavesomeblank

Forsomefieldstherewillbeadefaultvalue,

Ifyouenter'.',thefieldwillbeleftblank.

-----

CountryName(2lettercode)[AU]:

US

StateorProvinceName(fullname)[Some-State]:

NewHampshire

LocalityName(eg,city)[]:

Manchester

OrganizationName(eg,company)[InternetWidgitsPtyLtd]:

CUIST

OrganizationalUnitName(eg,section)[]:

ITSection

CommonName(eg,YOURname)[]:

localhost

EmailAddress[]:

huyuchengus@

Pleaseenterthefollowing'extra'attributes

tobesentwithyourcertificaterequest

Achallengepassword[]:

Anoptionalcompanyname[]:

D:

\Dkits\Apache2.2\bin>

其中有几个地方需要注意

EnterPEMpassphrase:

Verifying-EnterPEMpassphrase:

用于输入和重复输入密码的,密码长度不能小于4位

CommonName(eg,YOURname)[]:

localhost

用于输入客户端能够访问SSL的地址:

这里SSL服务器是在本地运行的,因此你可以输入localhost如果你的SSL地址运行网站主机上,那么这里需要输入例如了。

Anoptionalcompanyname[]:

留空,如果输入将会报错。

其他的提示输入部分,可以输入也可以留空,最重要的就是CommonName(eg,YOURname)[]:

这个变量,关系到你的SSL服务能不能够运行。

为Apache创建没有密码保护的key

下面需要为Apache创建一个没有密码保护的key了。

命令是opensslrsa-inserver.pem-outserver.key

运行结果如下

在这里你需要输入密码,这个密码是你在上一步输入过的。

如果没有错误,你将会看到writingRSAkey这句话后面没有任何内容和错误提示。

创建X.509证书

现在需要为Apache创建X.509证书了。

命令是:

opensslx509-inserver.csr-outserver.crt-req-signkeyserver.key-days365

结果如下:

如果没有错误,将会看到签名已经成功,后面有签名的详细信息和内容。

现在你再看看opensel.exe所在的文件夹下面是不是多了4个文件了,分别是:

server.pem,server.key,server.csr,server.crt

其实我们并不需要所有的这4个文件,我一向喜欢偷懒,就把这4个文件直接拷贝到conf文件夹下面保存。

重新启动错误

如果重新启动没有错误,但是还是不能访问。

这时候你需要检查日志文件,有一种可能是443端口的冲突,如果你的机器已经安装了IIS,那需要将IIS的web服务,FTP,SMTP服务全部关掉再重新启动。

如果既没有日志输出,也不能访问,那是因为配置文件没有被正确的载入,这时候你需要先在httpd.conf文件里面注释掉这句话Includeconf/extra/httpd-ssl.conf,然后重新启动Apache的服务。

等服务成功启动以后,再打开这句话,再重新启动服务。

这时候你就能看到日志的输出了。

否则不管你重新启动多少次,Apache还是只会载入老的httpd-ssl.conf文件,不会重新读取httpd-ssl.conf的。

如果在日志里面有警告

[FriAug1516:

15:

102008][warn]RSAservercertificateCommonName(CN)`localhost'doesNOTmatchservername!

?

[FriAug1516:

15:

102008][notice]Child3664:

Releasedthestartmutex

[FriAug1516:

15:

102008][warn]RSAservercertificateCommonName(CN)`localhost'doesNOTmatchservername!

?

那是因为你输入的SSL服务为localhost但是你Apache在安装的时候服务却不是localhost。

这时候你需要改几个地方。

httpd-ssl.conf文件中的

#ServerAdmin:

Youraddress,whereproblemswiththeservershouldbe

#e-mailed.Thisaddressappearsonsomeserver-generatedpages,such

#aserrordocuments.e.g.

#

ServerAdmin

将ServerAdmin变量中的改成admin@localhost

保存上述两个配置文件后重新启动Apache服务器,如果没有日志输出,则需要先在httpd.conf文件里面注释掉这句话Includeconf/extra/httpd-ssl.conf,然后重新启动Apache的服务。

等服务成功启动以后,再打开这句话,再重新启动服务。

在输出的日志里面应该不会包含有任何的警告信息了。

[FriAug1516:

29:

132008][notice]Parent:

Receivedrestartsignal--Restartingtheserver.

[FriAug1516:

29:

132008][notice]Child3908:

Exiteventsignaled.Childprocessisending.

[FriAug1516:

29:

132008][notice]Apache/2.2.9(Win32)mod_ssl/2.2.9OpenSSL/0.9.8hPHP/5.2.6configured--resumingnormaloperations

[FriAug1516:

29:

132008][notice]Serverbuilt:

Jun13200804:

04:

59

[FriAug1516:

29:

132008][notice]Parent:

Createdchildprocess2976

[FriAug1516:

29:

142008][notice]Child3908:

Releasedthestartmutex

[FriAug1516:

29:

142008][notice]Child2976:

Childprocessisrunning

[FriAug1516:

29:

142008][notice]Child2976:

Acquiredthestartmutex.

[FriAug1516:

29:

142008][notice]Child2976:

Starting64workerthreads.

[FriAug1516:

29:

142008][notice]Child2976:

Startingthreadtolistenonport443.

[FriAug1516:

29:

142008][notice]Child2976:

Startingthreadtolistenonport80.

[FriAug1516:

29:

152008][notice]Child3908:

Allworkerthreadshaveexited.

[FriAug1516:

29:

152008][notice]Child3908:

Childprocessisexiting

#Generalsetupforthevirtualhost

DocumentRoot"D:

/Dkits/Apache2.2/htdocs"

ServerNameCUIST_PC02.rochester.cuist.local:

443

ServerAdmin

ErrorLog"D:

/Dkits/Apache2.2/logs/error.log"

TransferLog"D:

/Dkits/Apache2.2/logs/access.log"

将ServerNameCUIST_PC02.rochester.cuist.local:

443变量中的CUIST_PC02.rochester.cuist.local:

443改成localhost:

443

将ServerAdmin变量中的改成admin@localhost

httpd.conf文件中的

(85.46KB)

2009-10-3008:

28

HTTP服务启动在80端口,SSL服务启动在443端口。

验证

在HTTP能正常访问的地址下面加上S变成https。

如果http:

//localhost/phpMyAdmin/index.php变化成https:

//localhost/phpMyAdmin/index.php

这时候应该能够看到一个证书警告的信息

(283.82KB)

2009-10-3008:

33

同意这个证书,看看是不是能够看到web页面了呀,如果能,则说明SSL已经被正确的配置到Apache服务里面来了。

可以轻松一下了喔。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 其它

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1