wampserver64本地启用https

我自己的环境:win10,wampserver64 3.1.3,php用的7.2.4,我由于装了visual studio2017,vc的那些环境是有的,根据需要自行安装环境

首先感谢https://blog.csdn.net/haolipengzhanshen/article/details/51278262,我是参考了这篇自己进行实践的

1.先打开apache的bin目录,我的是C:\wamp64\bin\apache\apache2.4.33\bin,shift+右键在此处打开powershell,我是管理员账户所以是powershell,一般是cmd,反正都要操作cmd的,如果使用powershell打开的还要使用cmd打开cmd

2.输入set OPENSSL_CONF=../conf/openssl.cnf,回车

3.输入openssl genrsa 1024>server.key,回车

4.输入openssl req -new -key server.key > server.csr,回车,除了Common Name都可以直接回车,这项填自己的域名,由于我有子站点的需求,我用的是*.gcud.gcud

5.将server.crt和和server.key复制到apace的配置目录,我的路径是C:\wamp64\bin\apache\apache2.4.33\conf

6.打开apache的ssl_module和socache_shmcb_module模块

7.打开apache配置文件置文件httpd.conf,默认路径是C:\wamp64\bin\apache\apache2.4.33\conf\nf\httpd.conf,把Include conf/extra/ra/httpd-ssl.conf前面的#去掉

8.打开apache额外配置目录的目录的httpd-ssl.conf文件,默文件,默认路径是C:\wamp64\bin\apache\apache2.4.33\conf\extra\ra\httpd-ssl.conf,将SSLCertificateFile,SSLCertificateKeyFile,SSLSessionCache,ErrorLog,TransferLog,CustomLog,改成自己的相应路径,看后缀应该都知道是什么

9.再把DocumentRoot改成网站所在路径,如果只打算弄一个https,路径改成项目所在就行了,ServerName改成localhost:443,一个的话改成自己的域名,第10可以跳过

10.在最后加上

<VirtualHost *:443>
ServerName gcud.gcud:443
DocumentRoot "C:/wamp64/www/gcud"
SSLCertificateKeyFile "C:/wamp64/bin/apache/apache2.4.33/conf/server.key"
SSLCertificateFile "C:/wamp64/bin/apache/apache2.4.33/conf/server.crt"
</VirtualHost>
<VirtualHost *:443>
ServerName source.gcud.gcud:443
DocumentRoot "C:/wamp64/www/source.gcud.gcud"
SSLCertificateKeyFile "C:/wamp64/bin/apache/apache2.4.33/conf/server.key"
SSLCertificateFile "C:/wamp64/bin/apache/apache2.4.33/conf/server.crt"
</VirtualHost>

11.在hosts文件加入自己的域名,如
127.0.0.1 gcud.gcud

127.0.0.1 source.gcud.gcud

12.重启apache,打开浏览器输入你设定的域名,如果是不存在的根域名,要自己手动在前面加https,浏览器会提示不安全,自己强制去就行,另外有子站点作为cdn的话,也要在浏览器里手动将域名打开允许,否则浏览器会拦截

猜你喜欢

转载自my.oschina.net/u/3470006/blog/2056001