CentOS系統上配置https服務

來源:互聯網
上載者:User

標籤:設定檔

在CentOS6.9(http2.2)配置https

在CentOS6.9和CentOS7分別實現配置

在CentOS6.9(http2.2)配置https

  建立前準備:

      安裝opensssl包  和 http2.2

1、在主機(192.168.109.100)建立私人CA

  (1)擷取私密金鑰

      650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604191124_17343.png" />

          注意:1、私密金鑰儲存路徑是按/etc/pki/tls/openssl.cnf設定檔規定的即/etc/pki/CA/private/

            2、做成的私密金鑰的許可權必須是600

            3、檔案名稱必須以.pem結尾

 

   (2)製作自簽證

        650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604191218_97518.png" />

    注意:1、自簽憑證路徑按/etc/pki/tls/openssl.cnf設定檔規定的即/etc/pki/CA/

             2、檔案名稱必須以.pem結尾

             3、-x509 選項只能是自己給自己發證時才用

     這時自己的主機就是CA了

 

   (3)為CA提供所需的目錄及檔案

          ~]# mkdir -pv /etc/pki/CA/{certs,crl,newcerts}(如果沒有這些檔案就建立,如果有就不用了)

         ~]# touch /etc/pki/CA/{serial,index.txt}

          ~]# echo 01 > /etc/pki/CA/serial

         650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604191247_39010.png" /> 

   2、在主機(192.168.109.103)做https

        建立一個虛擬機器主機

        因為是http2.2

        需要先關閉中心伺服器

    注意(專用於httpd-2.2):一般虛擬機器不要與中心主機混用;因此,要使用虛擬機器主機,得先禁用‘main‘主機;

禁用方法:注釋中心主機的DocumentRoot指令即可;


(1)建立一個虛擬機器主機和安裝mod_ssl模組

       安裝模組:

      650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604191356_37549.png" />

        vim /etc/httpd/conf.d/vir1.conf

            650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604191412_94383.png" />

                    

     (2)切換至/etc/httpd/ssl目錄

           mkdir /etc/httpd/ssl

           cd  /etc/httpd/ssl

 

           

     (3)擷取私密金鑰

           650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604191430_64611.png" />

     (4)產生認證簽署請求

        650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604191444_18510.png" /> 

(5)將請求發送給CA

     650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604191458_48017.png" />

 (6)CA 簽證

      650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604191519_62429.png" /> 

  (7)CA將認證發給客戶

      scp /etc/pki/CA/certs/http.crt [email protected]:/etc/httpd/ssl

 

  (8)修改ssl設定檔

        vim /etc/httpd//conf.d/ssl.conf

         650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604191537_46558.png" />

        650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604191552_80761.png" />

   (9)檢測文法和重啟服務

        httpd -t

       650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604191610_53205.png" />

  (10)將CA認證匯入用戶端瀏覽器

 (11)測試

     用web瀏覽器 輸入URL : https://www.lyy.com

     650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604191622_23419.png" />  

   測試成功

    

       

CentOS7(http2.4)上配置https

一、安裝httpd和mod_ssl服務

yum intall httpd mod_ssl

本主機IP:192.168.109.106

二、建立虛擬機器主機和擷取CA認證

     1、vim /etc/httpd/conf.d/vir1.conf

        650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604192405_45675.png" />

      2、擷取認證(在主機192.168.109.103  私人CA機構)

        (1)切換至/etc/httpd/ssl目錄

             mkdir /etc/httpd/ssl

             cd  /etc/httpd/ssl

        (2)擷取私密金鑰

             650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604192418_26865.png" />

        (3)產生認證簽署請求

             650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604192435_46313.png" />

        (4)將請求發送給CA

             650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604192446_71382.png" />

        (5)CA簽證

            650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604192500_74214.png" />

        (6)CA將認證發給本地主機(192.168.109.106)

              650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604192521_81758.png" />

 

               

         (7)文法檢測和重啟服務

              650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604192532_58593.png" />

三、測試

1、將認證匯入用戶端瀏覽器

2、訪問https://www.zq.com

  650) this.width=650;" src="http://www.178linux.com/wp-content/uploads/2017/06/20170604192546_24315.png" />

 配置成功

        

 

     

   


       


本文出自 “11952324” 部落格,請務必保留此出處http://11962324.blog.51cto.com/11952324/1934301

CentOS系統上配置https服務

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.