在默认情况下,Apache允许客户端进行匿名访问,但Apache也可以实现基于加密的认证访问。这里做一个DEMO的实现过程详解。
一、安装相应支持模块
首先在/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
[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
四、测试验证
[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 ]
点击Add Exception
点击View 可以查看这张自颁发的证书信息。
点击Confirm Security Exception,然后浏览器将显示页面内容。