关于https的介绍看这里:http://www.cnblogs.com/wuhuacong/p/4814708.html
一、用openssl生成KEY 生成自签名文件
1、doc进入Apache目录,将conf目录下的openssl.cnf文件拷贝到bin文件里面;bin目录中,可以看到openssl.exe文件;
2、bin目录下:openssl req -config openssl.cnf -new -out server.csr -keyout server.pem
其中有几个地方需要注意
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
用于输入和重复输入密码的,密码长度不能小于4位
Common Name (eg, YOUR name) []:localhost
用于输入客户端能够访问SSL的地址:这里SSL服务器是在本地运行的,因此你可以输入localhost如果你的SSL地址运行网站主机上,那么这里需 要输入例如www.admin.com了。
为Apache创建没有密码保护的key 下面需要为Apache创建一个没有密码保护的key了。
命令是openssl rsa -in server.pem -out server.key
输入你在上一步输入的密码
创建X.509证书 现在需要为Apache创建X.509证书了。
命令是:openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 365
如果没有错误,就会看到生成了4个文件server.pem,server.key,server.csr,server.crt
拷贝生成的server.key和server.crt文件到conf目录下
二、修改https.conf文件
去掉这两行的注释
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
三、修改conf/extra/httpd-ssl.conf文件
将conf/extra/httpd-ssl.conf文件中和Apache相关的路径和你电脑实际的Apache路径一一对应上
四、重启Apache
如果正常启动ok
如果存在错误,看下logs日志,可能是443端口冲突
Starting the Apache2a service
The Apache2a service is running.
[core:warn] [pid 21208:tid 508] AH00098: pid file D:/phpStudy/Apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Thu Oct 20 19:42:31.850752 2016] [mpm_winnt:notice] [pid 21208:tid 508] AH00455: Apache/2.4.10 (Win32) OpenSSL/0.9.8zb PHP/5.3.29 configured -- resuming normal operations
[Thu Oct 20 19:42:31.850752 2016] [mpm_winnt:notice] [pid 21208:tid 508] AH00456: Apache Lounge VC9 Server built: Jul 19 2014 13:20:51
[Thu Oct 20 19:42:31.850752 2016] [core:notice] [pid 21208:tid 508] AH00094: Command line: 'D:\\phpStudy\\Apache\\bin\\httpd.exe -d D:/phpStudy/Apache'
[Thu Oct 20 19:42:31.863753 2016] [mpm_winnt:notice] [pid 21208:tid 508] AH00418: Parent: Created child process 20428
搜索错误的原因,最终确定443端口冲突
netstat -ano | findstr "443"
根据查询出的结果的PID查看是哪个进程
tasklist | findstr "13394"
通过任务管理器关闭对应的进程
再次重启Apache即可
五、这样自己生成的签名,有些浏览器是不认可的,如果有需要,需要自行购买
祝,好运