apache实验

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

RHCE实验文档— APACHE配置

实验一: 实现安全的APACHE( https )

实验环境: Redhat 6.0平台

软件包: httpd-2.2.15-5.el6.x86_64.rpm mod_ssl.x86_64 1:2.2.15-5.el6.rpm

实验要求: 搭建一个基本的web服务,并且能够实现通过https协议访问.

步骤一: 安装软件包

[root@station ~]# yum -y install httpd mod_ssl

步骤二: 查看配置文件中证书路径是否启用.

[root@station ~]# vim /etc/httpd/conf.d/ssl.conf

# certificate can be generated using the genkey(1) command.

SSLCertificateFile /etc/pki/tls/certs/localhost.crt –公钥

# Server Private Key:

# If the key is not combined with the certificate, use this

# directive to point at the key file. Keep in mind that if

# you've both a RSA and a DSA private key you can configure

# both in parallel (to also allow the use of DSA ciphers, etc.)

SSLCertificateKeyFile /etc/pki/tls/private/localhost.key –私钥

注:红色字体分别指出了公钥和私钥的路径,在企业六中默认自动创建了这两个证书.

可以直接使用这两个自签证书.

步骤三:创建用于测试的主页面:

[root@station ~]# echo "this is test for https" >/var/www/html/index.html 步骤四:启动服务并将服务设置为开机自启动

[root@station ~]# service httpd start

Starting httpd: [ OK ]

[root@station ~]# chkconfig httpd on

步骤五:测试

总结:实验到第五步就已经实现了一个最基本的https的web服务器,在实际生产环境中,证书部分可以通过搭建CA证书服务器来签发,或者向第三方的权威CA服务器来申请,从而提高证书的可信性.如果使用第三方的证书时,大家需要注意调整证书的路径.

实验二:创建基于不同域名的虚拟主机

实验环境: Redhat 6.0平台

软件包: httpd-2.2.15-5.el6.x86_64.rpm

实验要求: 下载服务器文件ftp: ///pub/x86_64/rhce/station.html到

指定目录/var/www/html,实现通过域名能够访问。建一个web虚拟主机,下载服务器文件ftp: ///pub/x86_64/rhce/www.html,到指定目录/virtual ,要求通过域名能够访问

步骤一: 安装软件包

[root@station ~]# yum -y install httpd

步骤二:创建实验所要的目录并调整其selinux环境

[root@station ~]# mkdir /virtual

[root@station ~]# chcon --reference /var/www/html/ /virtual/

[root@station ~]# ll -Zd /virtual/

drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /virtual/

步骤三:下载所需的测试页面并更改其主面名.

[root@station html]# cd /virtual/

[root@station virtual]# wget ftp:///pub/x86_64/rhce/www.html

[root@station virtual]#mv www.html index.html

[root@station virtual]# cd /var/www/html/

[root@station html]# wget ftp:///pub/x86_64/rhce/station.html

[root@station html]#mv station.html index.html

步骤四:检查各虚拟主机主页的selinux环境

[root@station html]# ll -Z index.html

-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 index.html

[root@station html]# ll -Z /virtual/index.html

-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 /virtual/index.html

步骤五:修改主配置文件.

NameVirtualHost 172.24.20.15

DocumentRoot /var/www/html

ServerName

DocumentRoot /virtual

ServerName

步骤六:重启httpd服务,并测试.

[root@station html]# service httpd restart

Stopping httpd: [ OK ]

Starting httpd: [ OK ]

[root@station html]# curl

this is station site for RHCE6.0

[root@station html]# curl

this is www site for RHCE6.0

相关文档
最新文档