linux搭建https伺服器

來源:互聯網
上載者:User

   一、 安裝準備

  1. 安裝Openssl

  要使Apache支援SSL,需要首先安裝Openssl支援。這裡使用的是openssl-0.9.8k.tar.gz

  下載Openssl:http://www.openssl.org/source/

  tar -zxf openssl-0.9.8k.tar.gz //解壓安裝包

  cd openssl-0.9.8k //進入已經解壓的安裝包

  ./config //配置安裝。推薦使用預設配置

  make && make install //編譯及安裝

  openssl預設將被安裝到/usr/local/ssl

  2. 安裝Apache

  從http://httpd.apache.org/下載httpd原始碼,這裡使用的是httpd2.2.22;

  ./configure --prefix=/usr/local/httpd2.2.22 --enable-so --enable-ssl --with-ssl=/usr/local/ssl --enable-mods-shared=all //配置安裝。推薦動態編譯模組

  make && make install

  動態編譯Apache模組,便於模組的載入管理。Apache 將被安裝到/usr/local/apache

  二、 產生認證

  為了快速搭建好可用的https伺服器,需要在/usr/local/httpd2.2.22/conf/目錄下

  (也可以在別的目錄下產生,將產生後的檔案拷貝到/usr/local/httpd2.2.22/conf/目錄下)

  依次運行以下命令:

  1. openssl req -new -text -out server.req

  2. openssl rsa -in privkey.pem -out server.key

  3. openssl req -x509 -in server.req -text -key server.key -out server.crt

  具體的可以參考openssl文檔;

  三、 Apache 的配置

  開啟apache安裝目錄下conf目錄中的httpd.conf檔案,找到

  #LoadModule ssl_module modules/mod_ssl.so

  刪除行首的配置語句注釋符號“#”

  儲存退出。

  開啟apache安裝目錄下conf目錄中的ssl.conf檔案,找到

  在設定檔中尋找以下配置語句

  SSLCertificateFile conf/ssl.crt/server.crt 將伺服器憑證配置到該路徑下

  SSLCertificateKeyFile conf/ssl.key/server.key 將伺服器憑證私密金鑰配置到該路徑下

  #SSLCertificateChainFile conf/ssl.crt/ca.crt 刪除行首的“#”號注釋符,並將中級CA認證intermediate.crt配置到該路徑下

  儲存退出,並重啟Apache。重啟方式:

  進入Apache安裝目錄下的bin目錄,運行如下命令

  ./apachectl -k -stop

  ./apachectl start

  通過https方式訪問您的網站,測試網站認證的安裝配置。

  此時即可以通過http和https訪問搭建好的伺服器;

        :更多精彩教程請關注三聯電腦教程欄目,三聯電腦辦公群:189034526歡迎你的加入

聯繫我們

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