1. 程式人生 > >wampserver 配置https證書

wampserver 配置https證書

author:he qq:760863706 wamp:2.5 ,3.0.6 date:2018-10-23

讓wamp具有HTTPS訪問許可權,需要配置安全協議證書,本文參考 https://www.youtube.com/watch?v=TH6evGKgy20 視訊內容,並在本地 wamp2.5 和 wamp3.0.6 兩個伺服器上配置測試,都能滿足需求,現做一下記錄,以備後續查詢

1:下載openssl.exe

2:cmd下執行命令 結合本機,cmd下切換到 D:\wamp\bin\apache\apache2.4.9\bin,然後依次執行執行

openssl genrsa -aes256 -out private.key 2048
openssl rsa -in private.key -out private.key
openssl req -new -x509 -nodes -sha1 -key private.key -out certificate.crt -days 36500 -config D:\wamp\bin\apache\apache2.4.9\conf\openssl.cnf

執行命令期間,會讓輸入密碼,或者國家地區一類的 ,按提示輸入即可,執行結束後會在 D:\wamp\bin\apache\apache2.4.9\bin 目錄下生成 certificate.crt 和 private.key 兩個檔案,複製這兩個檔案,然後切換目錄到 D:\wamp\bin\apache\apache2.4.9\conf 下,建立key資料夾,放入這兩個檔案

3:配置更改

開啟apache 配置檔案, D:\wamp\bin\apache\apache2.4.9\conf\httpd.conf,修改3項內容,去除預設的 #

Include conf/extra/httpd-ssl.conf
LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so

然後開啟配置檔案 D:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-ssl.conf ,在原預設配置中做如下修改

DocumentRoot "D:/wamp/www"
ServerName localhost:443
ServerAdmin [email protected]
ErrorLog "D:/wamp/bin/apache/apache2.4.9/logs/error.log"
TransferLog "D:/wamp/bin/apache/apache2.4.9/logs/access.log"

SSLCertificateFile "D:/wamp/bin/apache/apache2.4.9/conf/key/certificate.crt"
SSLCertificateKeyFile "D:/wamp/bin/apache/apache2.4.9/conf/key/private.key"

CustomLog "D:/wamp/bin/apache/apache2.4.9/logs/ssl_request.log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

完成配置後,在保證php.ini中的 extension=php_openssl.dll 引入的情況下,重啟伺服器,然後瀏覽器輸入 https://localhost:443 即可通過https訪問我們的網站了,在wamp3.0.6 的情況下配置流程是一樣的 ,只是 在修改 httpd-ssl.conf 這個檔案時把預設路徑更改為伺服器實際的路徑就可以了