RHCE试题EX300详解(十五)配置 web 内容访问

题目要求:配置 web 内容访问

在您 server0 上的 web 服务器的 DocumentRoot 目录下创建一个名为 private 的目录,要求:

  • l 从 http://classroom.example.com/content/permission.html 下载文件到这个目录,
  • l 并重命名为 index.html,不要修改文件内容。
  • l 从 server0 上,任何人都可以浏览 private 的内容,但是从其他系统不能访问这个目录的内容

知识点小贴士:

Apache是Linux下的Web服务器,Apache用的是静态页面,需要加载模块来支持动态页面,会动态实时的调整进程来处理,最合理的使用多核CPU资源,支持虚拟主机应用,多个Web站点共享一个IP地址。

Apache和Selinux之间的关系,我们进入/var/www/html/目录下,通过ll –Z查看目录下index.html Selinux属性,通过命令ps –auxZ|grep http查看httpd的进程,这些http进程都有httpd_t的Selinux上下文属性,Selinux就规定了http_t这类的进程上下文属性可以访问httpd_sys_content_t这类文件的上下文属性,从而保证了网站的内容可以被访问。

解题步骤:

(1)创建目录:

<code>[root@server0 ~]# mkdir /var/www/{html,virtual}/private/<code>

(2)下载文件到指定的目录:

<code>[root@server0 ~]# wget -O /var/www/html/private/index.html http://classroom.example.com/content/permission.html
--2020-03-26 08:25:25--  http://classroom.example.com/content/permission.html

Resolving classroom.example.com (classroom.example.com)... 172.25.254.254
Connecting to classroom.example.com (classroom.example.com)|172.25.254.254|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9 [text/html]
Saving to: ‘/var/www/html/private/index.html’
100%[=====================>] 9           --.-K/s   in 0s     
2020-03-26 08:25:25 (842 KB/s) - ‘/var/www/html/private/index.html’ saved [9/9]/<code>
<code> [root@server0 ~]# wget -O /var/www/virtual/private/index.html http://classroom.example.com/content/permission.html
--2020-03-26 08:25:46--  http://classroom.example.com/content/permission.html
Resolving classroom.example.com (classroom.example.com)... 172.25.254.254
Connecting to classroom.example.com (classroom.example.com)|172.25.254.254|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9 [text/html]
Saving to: ‘/var/www/virtual/private/index.html’
100%[=====================>] 9           --.-K/s   in 0s     
2020-03-26 08:25:46 (766 KB/s) - ‘/var/www/virtual/private/index.html’ saved [9/9]/<code>

(3)新建一个配置文件:

<code>[root@server0 ~]# vim /etc/httpd/conf
conf/           conf.d/         conf.modules.d/
[root@server0 ~]# vim /etc/httpd/conf
conf/           conf.d/         conf.modules.d/
[root@server0 ~]# vim /etc/httpd/conf.d/
autoindex.conf         vhos-server0-ssl.conf
README                 vhost-server0.conf
ssl.conf               webapp0.conf
userdir.conf           welcome.conf/<code>
<code>[root@server0 ~]# vim /etc/httpd/conf.d/server0-private.conf/<code>


RHCE试题EX300详解(十五)配置 web 内容访问


注释:在配置文件中输入以下内容

<code><directory>
   Require host server0.example.com
/<directory>
<directory>
   Require host server0.example.com
/<directory>/<code>

(4)重启httpd服务:

<code>[root@server0 ~]# systemctl restart httpd.service/<code>

(5)在Server0上验证:

<code>[root@server0 ~]# firefox http://www0.example.com/private/<code>


RHCE试题EX300详解(十五)配置 web 内容访问


<code>[root@server0 ~]# firefox http://webapp0.example.com/private/<code>


RHCE试题EX300详解(十五)配置 web 内容访问


(6)在desktop0上验证:

<code>[root@desktop0 ~]# firefox http://www0.example.com/private/<code>


RHCE试题EX300详解(十五)配置 web 内容访问


<code>[root@desktop0 ~]# firefox http://webapp0.example.com/private/<code>


RHCE试题EX300详解(十五)配置 web 内容访问


分享到:


相關文章: