使用wampserver网站web坏境搭建https服务器教程
相信很多站长都是使用的Windows主机服务器搭建的网站,而现如今https化趋势越来越重要的情况下,为自己的Windows主机服务器配置ssl证书就越发的需要尽早进行了,今天服务器租用网就为大家分享篇使用wampserver网站web坏境搭建https服务器教程,助力站长们早日将自己的网站实现全站https化。
一、设置环境变量
1、管理员权限运行CMD(快捷键win+r,输入cmd),cd D:\wamp\bin\apache\Apache2.4.9\conf
2、set OPENSSL_CONF=..\conf\openssl.cnf
二、生成server.key
cd D:\wamp\bin\apache\Apache2.4.9\bin
openssl genrsa 1024>server.key
三、生成server.csr
openssl req -new -key server.key > server.csr
然后依次输入CN、SH、SH、直接回车、直接回车、192.168.1.104、随意输入一个邮箱 、直接回车、直接回车
注意:其中的Common Name只能输入域名或IP:192.168.1.104
Common Name 必须和 httpd.conf 中 server name 必须一致, 否则 apache 不能启动(启动 apache 时错误提示为: server RSA certificate CommonName (CN) `Kedou’ does NOT match server name!? )
最后的密码和公司名称可以为空
操作截图
四、生成server.crt
openssl req -x509 -days 365 -key server.key -in server.csr > server.crt
在D:\wamp\bin\apache\Apache2.4.9\bin把 server.crt、server.csr、server.key
三个文件复制到D:\wamp\bin\apache\Apache2.4.9\conf 下
五、配置httpd:
打开 'D:\wamp\bin\apache\Apache2.4.9\conf\httpd.conf' 取消注释
Include conf/extra/httpd-ssl.conf
LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
六、配置ssl:
打开D:\wamp\bin\apache\Apache2.4.9\conf\extra\httpd-ssl.conf
"SSLCertificateKeyFile…"这行改成
SSLCertificateKeyFile "D:/wamp/bin/apache/apache2.4.9/conf/server.key"
SSLSessionCache这行改成
SSLSessionCache "shmcb:D:/wamp/bin/apache/apache2.4.9/logs/ssl_scache(512000)"
修改DocumentRoot 为DocumentRoot "D:/wamp/www/"
ServerName 192.168.1.104
ErrorLog "D:/wamp/bin/apache/apache2.4.9/logs/error.log"
TransferLog "D:/wamp/bin/apache/apache2.4.9/logs/access.log"
SSLEngine on
SSLCertificateFile "D:/wamp/bin/apache/apache2.4.9/conf/server.crt"
SSLCertificateKeyFile "D:/wamp/bin/apache/apache2.4.9/conf/server.key
七 、在D:/wamp/www/ 下新建index.php
写入代码
<?php
phpinfo();
?>
八、重启wampserver。
浏览器输入:https://192.168.1.104/index.php
访问截图