linux下apache https 虛擬機器主機配置

來源:互聯網
上載者:User

標籤:style   class   blog   code   http   color   

如果單純只想在傳輸資料時加密傳輸,那麼ssl認證是不需要認證的,但是瀏覽器開啟時會有警告資訊。假設我們做的不是一個公眾產品那麼也還好啦。

如下是今天學習時的一個筆記,其實我用的是真實環境。

環境:CentOS 64, 32bit;Apache 2.2.15;

1.檢查apache是否安裝了mod_ssl.so模組。

檢查方法是查看是否在modules(/etc/httpd/modules/)下存在。不存在那麼安裝(yum -y install mod_ssl)。

2.產生認證和密鑰

1)產生密鑰

命令:openssl genrsa 1024 > server.key

說明:用128位rsa演算法產生密鑰,得到server.key檔案。

2) 產生認證請求檔案

命令:openssl req -new -key server.key > server.csr

說明:用步驟1產生的密鑰產生認證請求檔案server.csr,這一步會有很多問題,按照自己的需要輸入即可。

3): 產生認證

命令:openssl req -x509 -days 365 -key server.key -in server.csr > server.crt

說明:用步驟1,2的密鑰和認證請求產生認證server.crt,-days參數指明認證有效期間,單位為天。

3.修改apache設定檔(httpd.conf)

1)添加監聽連接埠

Listen 443

2)載入mod_ssl模組

LoadModule ssl_module modules/mod_ssl.so

3)配置虛擬機器主機

NameVirtualHost 121.127.246.429:443<VirtualHost 121.127.246.429:443>DocumentRoot /data/www/1234567ServerName 1234567.mo.comSSLEngine OnSSLOptions +StrictRequireSSLCertificateFile /data/conf/httpd/server.crtSSLCertificateKeyFile /data/conf/httpd/server.keyDirectoryIndex index.html index.php<Directory "/data/www/1234567">#Options Indexes FollowSymLinksOptions FollowSymLinksAllowOverride NoneOrder allow,denyAllow from all</Directory></VirtualHost>
4.訪問

https://1234567.mo.com


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.