溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

RHEL6.3下如何簡單配置Apache https

發(fā)布時間:2021-11-12 17:41:27 來源:億速云 閱讀:139 作者:柒染 欄目:云計(jì)算

今天就跟大家聊聊有關(guān)RHEL6.3下如何簡單配置Apache https,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

在默認(rèn)情況下,Apache允許客戶端進(jìn)行匿名訪問,但Apache也可以實(shí)現(xiàn)基于加密的認(rèn)證訪問。這里做一個DEMO的實(shí)現(xiàn)過程詳解。

一、安裝相應(yīng)支持模塊
首先在/etc/httpd/conf.d下查看有沒有ssl.conf文件,如果沒有需要安裝mod_ssl加密支持模塊。

[root@localhost Desktop]# cd /etc/httpd/conf.d

[root@localhost conf.d]# ls

mod_dnssd.conf  README  welcome.conf

使用YUM源來安裝

[root@localhost rhel6]# yum -y install mod_ssl

Loaded plugins: product-id, refresh-packagekit, security, subscription-manager

Updating certificate-based repositories.

Unable to read consumer identity

RHEL                                                     | 4.0 kB     00:00 ... 

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package mod_ssl.i686 1:2.2.15-15.el6_2.1 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

================================================================================

 Package         Arch         Version                        Repository    Size

================================================================================

Installing:

 mod_ssl         i686         1:2.2.15-15.el6_2.1            RHEL          88 k

Transaction Summary

================================================================================

Install       1 Package(s)

Total download size: 88 k

Installed size: 181 k

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : 1:mod_ssl-2.2.15-15.el6_2.1.i686                             1/1 

Installed products updated.

  Verifying  : 1:mod_ssl-2.2.15-15.el6_2.1.i686                             1/1 

Installed:

  mod_ssl.i686 1:2.2.15-15.el6_2.1                                           

Complete!

[root@localhost conf.d]# ls

mod_dnssd.conf  README  ssl.conf  welcome.conf

二、加密配置  
在ssl.conf文件中有這么兩句,指出了證書和私鑰的存放路徑  
 

SSLCertificateFile /etc/pki/tls/certs/localhost.crt

SSLCertificateKeyFile /etc/pki/tls/private/localhost.key

三、證書生成

[root@localhost conf.d]# cd /etc/pki/tls/certs

[root@localhost certs]# ls

ca-bundle.crt  ca-bundle.trust.crt  localhost.crt  make-dummy-cert  Makefile

先刪除原有的localhost.crt證書文件,再有make命令生成一個測試用的證書文件  
 

[root@localhost certs]# rm -rf localhost.crt 

[root@localhost certs]# make testcert

umask 77 ; \

/usr/bin/openssl req -utf8 -new -key /etc/pki/tls/private/localhost.key -x509 -days 365 -out /etc/pki/tls/certs/localhost.crt -set_serial 0

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) [US]:CN

State or Province Name (full name) []:

Locality Name (eg, city) [Default City]:Beijing

Organization Name (eg, company) [Default Company Ltd]:Tianli

Organizational Unit Name (eg, section) []:RedHat

Common Name (eg, your name or your server's hostname) []:test1.demo.com

Email Address []:

[root@localhost certs]# 

四、測試驗(yàn)證

[root@localhost certs]# cd /var/www/html

[root@localhost html]# ls

[root@localhost html]# touch index.html

[root@localhost html]# echo "welcomt to beijing" > index.html

[root@localhost html]# cat index.html

welcome to beijing

[root@localhost html]# service httpd restart

Stopping httpd:                                            [  OK  ]

Starting httpd:                                            [  OK  ]

[root@localhost html]# links -dump http://test1.demo.com

   welcome to beijing  
使用http顯示頁面正常

[root@localhost html]# links -dump https://test1.demo.com

ELinks: SSL error  
使用https顯示頁面則出現(xiàn)SSL error

下面使用瀏覽器看一下效果

[root@localhost html]# firefox

在地址欄中輸入https://test1.demo.com

RHEL6.3下如何簡單配置Apache https

在如上頁面中,點(diǎn)擊I Understand the Risks選項(xiàng)

RHEL6.3下如何簡單配置Apache https

點(diǎn)擊Add Exception

RHEL6.3下如何簡單配置Apache https

點(diǎn)擊View 可以查看這張自頒發(fā)的證書信息。

RHEL6.3下如何簡單配置Apache https

點(diǎn)擊Confirm Security Exception,然后瀏覽器將顯示頁面內(nèi)容。

RHEL6.3下如何簡單配置Apache https

看完上述內(nèi)容,你們對RHEL6.3下如何簡單配置Apache https有進(jìn)一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI