Apache配置SSL證書實現加密訪問

2021-08-31 01:22:00 字數 1569 閱讀 2913

首先,確保你的apache編譯了ssl模組,這是支援ssl證書必要的條件(如果沒有,請編譯,【開啟phpstudy】》【其他選項選單】》【php擴充套件】》【php-openssl】前面勾選上)。

開啟 apache 安裝目錄下 conf 目錄中的 httpd.conf 檔案,找到以下內容並去掉前面的「#」注釋符,使得ssl模組生效(如果該模組已去掉注釋,請不用操作)。

接著搜尋以下內容:【include conf/vhosts.conf】,在其下面增加一條引用內容:【include conf/vhostssl.conf】,如下圖所示

apache 安裝目錄下 conf 資料夾中建立乙個vhostssl.conf配置檔案。可以複製httpd.conf檔案另存為vhostssl.conf,按照80的配置,另起乙個virtualhost443,vhostssl.conf檔案中的所有內容如下所示:

listen 443

documentroot 「d:\www\webmulu」

servername www.example.com

serveralias example.com

sslengine on

sslprotocol tlsv1 tlsv1.1 tlsv1.2

sslciphersuite high:medium:!anull:!md5

sslcertificatefile 「d:\phpstudy\apache\cert\public.pem」

sslcertificatekeyfile 「d:\phpstudy\apache\cert\21564852664745.key」

sslcertificatechainfile 「d:\phpstudy\apache\cert\chain.pem」

options +indexes +followsymlinks +execcgi

allowoverride all

order allow,deny

allow from all

require all granted

注意:其中的網域名稱資訊替換成所申請ssl證書繫結的網域名稱,sslciphersuite、sslcertificatefile、sslcertificatekeyfile、sslcertificatechainfile,結合所申請的ssl證書給的配置資訊與自己所建立的cert證書目錄來配置;vhostssl.conf檔名沒有限制要求,可以根據自己的想要的重新命名,不過一定要跟httpd.conf 檔案中引用的檔名稱一樣!

重啟apache(有可能報錯,看一下443埠是否被防火牆攔截或被占用);apache正常重啟後,在瀏覽器裡面輸入帶有https的**就能看到安全鎖出來啦;最後備份好您的ssl證書!

end配置完ssl證書,我們需要進行站點301重定向,將http的位址強制跳轉到https位址,apache環境下,在站點根目錄新增.htaccess檔案,如圖所示

在.htaccess檔案中新增以下內容:

然後儲存檔案,並將檔案上傳到**根目錄,如圖所示

配置ssl證書 Apache配置SSL證書指引

1 使用yum安裝apache yum install httpd y2 修改測試頁面 vim var www html index.hemlps 修改為測試內容,我這裡修改的是 this is a test page.3 啟動服務 service httpd start4 訪問測試 1 安裝ssl...

apache 配置ssl服務 證書

lz今天配置了一整天,看著官方教程來各種錯誤。連apache都啟動不了 1 各種埠占用 2 無名錯誤。其實按著官方文件來就差不多了,要懂得看錯誤,這裡附上官方文件 接下來開始配置 1.啟動apache命令 systemctl start httpd.service 注意不是 service http...

Apache的SSL證書的安裝配置

1.openssl 的apache,並進行安裝。apache 版本如 2.配置 apache 下httpd.conf 檔案。loadmodule ssl module modules mod ssl.so 刪除行首的配置語句注釋符號 3.修改 apache 下httpd ssl 檔案。1 開啟 ap...