1. 程式人生 > >WampServer 打造 https 站(上) 圖文詳解

WampServer 打造 https 站(上) 圖文詳解

1 .宣告
我的wampserver 路徑 是 C:\wamp
wampserver 的版本是 WampServer Version 2.5
Apach 的版本是 2.4.9
作業系統是 win10;
本機區域網id 192.168.31.108
這裡寫圖片描述

步驟
1. 把 C:\wamp\bin\apache\apache2.4.9\bin
的 ssleay32.dll,libeay32.dll ,openssl.exe三個檔案複製到 C:\Windows\System32這個目錄下。
2. 生成伺服器證書
開啟cmd 命令列 輸入
跳轉到 cd C:\wamp\bin\apache\apache2.4.9\bin 回車
這裡寫圖片描述


輸入
openssl req -new -out server.csr -config ../conf/openssl.cnf
按回車鍵這裡寫圖片描述
輸入 whatisjava
按回車鍵
這裡寫圖片描述
輸入 whatisjava
按回車鍵
這裡寫圖片描述
輸入 CN
按回車鍵
這裡寫圖片描述
輸入CHONGQING
按回車鍵
這裡寫圖片描述
輸入CHONGQING
按回車鍵這裡寫圖片描述

輸入CHONGQING
按回車鍵

輸入CHONGQING
按回車鍵
這裡寫圖片描述

輸入你的域名 或者伺服器ip 我的是本地測試 輸入我伺服器ip
按回車鍵
這裡寫圖片描述
輸入你的郵箱
按回車鍵
這裡寫圖片描述
輸入whatisjava
按回車鍵
這裡寫圖片描述
二次輸入whatisjava
如圖
這裡寫圖片描述

這時候 C:\wamp\bin\apache\apache2.4.9\bin 生成了2個檔案
privkey.pem ,server.csr 2個檔案。
然後 在C:/wamp/bin/apache/apache2.4.9/ 下面建立一個ssh 資料夾 並生成的2個檔案拷貝進去

生成私匙
輸入 openssl rsa -in privkey.pem -out server.key
按回車
這裡寫圖片描述

輸入whatisjava
按回車鍵這裡寫圖片描述
沒報錯 恭喜你就成功了

建立證書 server.crt
輸入
openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 365
按回車這裡寫圖片描述


出現ok 就成功了

在 C:\wamp\bin\apache\apache2.4.9\bin 目錄下 找到
剛剛生成 server.key 和 server.csr 並複製到 剛剛建立的那個ssh 資料夾裡面 也就是C:\wamp\bin\apache\apache2.4.9\ssh 這個目錄下面
此時的目錄機構這裡寫圖片描述

證書生成好了 下一步就是 修改配置檔案了

Step2**** -> Copy the server.key and server.crt files.

2a) In the conf folder of apache2.2.8 folder, create two folders named as ssl.key and ssl.crt

2b) copy the server.key file to ssl.key folder and server.crt file to ssl.crt

*Step3*** -> Edit the httpd.conf file and php.ini

3a) In httpd.conf file, remove the comment ‘#’ at the line which says: LoadModule ssl_module
modules/mod_ssl.so

3b) In httpd.conf, remove the comment ‘#’ at the line which says: Include
conf/extra/httpd_ssl.conf
Then move that line after this block ….

3c) open the php.ini file located in apache2.2….\bin folder, remove the comment ‘;’ at the line
which says: extension=php_openssl.dll

*Step4** -> Edit the httpd_ssl.conf file in the folder name, extra

4a) Find the line which says “SSLMutex ….” and change it to “SSLMutex default” without quotes

4b) Find the line which says: . Right after it, change the line which says “DocumentRoot …” to DocumentRoot “C:/wamp/www/” with quotes. Change the line “ErrorLog….” to Errorlog logs/sslerror_log. Change the line “TransferLog ….” to TransferLog logs/sslaccess_log

4c) SSL crt file: Change the line “SSLCertificateFile ….” to SSLCertificateFile “conf/ssl.crt/server.crt”

4d) SSL key file: Change the line “SSLCertificateKeyFile ….” to SSLCertificateKeyFile “conf/ssl.key/server.key”

4e) Change the line which says