RHEL4下配置HTTPS

來源:互聯網
上載者:User
為了簡單明了,先採用RPM包的方式安裝Apache伺服器。

# cd /misc/cd/RedHat/RPMS/  //進入光碟片的包存放目錄
# rpm -ivh rpmdb-redhat-4-0.20070421.i386.rpm //安裝這個包的目的是便於解決有些程式的依賴性關係
# rpm -ivh --aid httpd-2.0.52-32.ent.i386.rpm //加--aid自動解決包的依賴性關係,因此前面已經安裝了rpmdb包
# rpm -ivh mod_ssl-2.0.52-32.ent.i386.rpm  //安裝這個包的目的是實現https
# echo 'this is my first page!' > /var/www/html/index.html //建立一個預設首頁放到apache定義的預設主目錄中
# service httpd start //啟動伺服器

在瀏覽器中輸入 https://伺服器IP 安裝認證就可以實現安全的HTTP了。

但是這時候的認證是mod_ssl自動產生的,資訊並不是我們自己想要的!所以我們可以用下面的方法製作自己的認證。

# cd /etc/httpd/conf   //進入apache設定檔存放目錄
# rm -f ssl.*/server.*  //將mod_ssl自動安裝的相關認證和簽名檔案刪除
# openssl genrsa -des3 1024 > ssl.key/server.key //產生私密金鑰檔案(Private Key)該檔案要求輸入口令。
# openssl rsa -in ssl.key/server.key -out ssl.key/server.key //如果不想使用口令可以去掉,這時會要求輸入產生時設定的口令。

# openssl req -new -key ssl.key/server.key -out ssl.csr/server.csr  //產生認證簽章要求檔案(Certificate Signing Request)
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:CH    //輸入國家名稱
State or Province Name (full name) [Berkshire]:BeiJing  //省名
Locality Name (eg, city) [Newbury]:Beijing //城市
Organization Name (eg, company) [My Company Ltd]:XHCE  //組織名稱
Organizational Unit Name (eg, section) []:BJXH //單位名稱
Common Name (eg, your name or your server's hostname) //根據具體情況填寫
Email Address []:weisheng213@126.com //郵箱
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:  //質詢密碼,可以不寫
An optional company name []: //可以不寫

# openssl x509 -in ssl.csr/server.csr -out ssl.crt/server.crt -req -signkey ssl.key/server.key -days 365 //讓伺服器自己當認證簽名伺服器,安全電子商務中需要向第三方商業機構申請。
Signature ok
subject=/C=CH/ST=BeiJing/L=Beijing/O=XHCE/OU=BJXH/CN=
Getting Private key

# vi ../conf.d/ssl.conf  //編輯mod_ssl的主設定檔將
#DocumentRoot "/var/www/html" 前面的#號去掉

# service httpd restart  //重啟apache伺服器以讀取新的認證資訊

聯繫我們

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