apache配置虚拟主机的作用是什么意思_apache是一种什么服务器

apache配置虚拟主机的作用是什么意思_apache是一种什么服务器题目要求:配置虚拟主机在 server0 上扩展您的 WEB 服务器,为站点 http://webapp0.example.com 创建一个虚拟主机。l 设置 DocumentRoot 为 /var/www/virtuall 从 http://classroom

题目要求:配置虚拟主机

在 server0 上扩展您的 WEB 服务器,为站点
http://webapp0.example.com 创建一个虚拟主机。

  • l 设置 DocumentRoot 为 /var/www/virtual
  • l 从 http://classroom.example.com/content/extend.html 下载文件
  • l 并重命名为 index.html 不要对文件 index.html 的内容做任何修改
  • l 将文件 index.html 放到虚拟机的 DocumentRoot 目录下
  • l 确保 floyd 用户能够在 /var/www/virtual 目录下创建文件

注意: 原始站点 http://www0.example.com 必须仍然能够访问,

名称服务器 classroom.example.com 提供对主机名 webapp0.example.com 的域名解析

知识点小贴士:

Apache服务器可利用虚拟主机功能在一台服务器上设置多个Web站点,Apache支持两种类型的虚拟主机:基于IP地址的虚拟主机和基于域名的虚拟主机。基于IP地址的各虚拟主机使用同一IP地址的不同端口,或者是使用不同的IP地址。用户可直接使用IP地址来访问此类虚拟主机。

解题步骤:

(1)查看主机名解析

[root@server0 ~]# host webapp0.example.com webapp0.example.com is an alias for server0.example.com. server0.example.com has address 172.25.0.11

(2)根据题意,创建目录,并设置权限:

[root@server0 ~]# mkdir /var/www/virtual [root@server0 ~]# setfacl -m u:floyd:rwx /var/www/virtual/

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

[root@server0 ~]# wget -O /var/www/virtual/index.html http://classroom.example.com/content/extend.html --2020-03-26 08:12:23--  http://classroom.example.com/content/extend.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: 8 [text/html] Saving to: ‘/var/www/virtual/index.html’ 100%[=====================>] 8           --.-K/s   in 0s      2020-03-26 08:12:24 (348 KB/s) - ‘/var/www/virtual/index.html’ saved [8/8] [root@server0 ~]# ls dZ /var/www/html/  /var/www/virtual/ ls: cannot access dZ: No such file or directory /var/www/html/: index.html /var/www/virtual/: index.html

(4)编辑配置文件:

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

apache配置虚拟主机的作用是什么意思_apache是一种什么服务器

webapp0.conf配置文件

注释:

<VirtualHost *:80>    DocumentRoot "/var/www/virtual"    servername webapp0.example.com </VirtualHost>

(5)重启httpd服务

[root@server0 ~]# systemctl restart httpd

(6)验证:

[root@server0 ~]# firefox http://webapp0.example.com

apache配置虚拟主机的作用是什么意思_apache是一种什么服务器

2024最新激活全家桶教程,稳定运行到2099年,请移步至置顶文章:https://sigusoft.com/99576.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。 文章由激活谷谷主-小谷整理,转载请注明出处:https://sigusoft.com/17295.html

(0)
上一篇 2024年 9月 16日
下一篇 2024年 9月 16日

相关推荐

关注微信