天天看点

RHCE7参考答案(14)配置虚拟主机

14.配置虚拟主机

在server0上扩展您的web服务器,为站点http://www0.example.com创建一个虚拟主机,然后执行下述步骤:

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

    注意:原始站点http://server0.example.com必须仍然能够访问,名称服务器example.com提供对主机名www0.example.com的域名解析。

[[email protected] ~]# mkdir /var/www/virtual
[[email protected] ~]# wget http://classroom.example.com/pub/materials/www.html -O /var/www/virtual/index.html
[[email protected] virtual~]# useradd fleyd
[[email protected] virtual~]# setfacl -m u:fleyd:rwx /var/www/virtual/
[[email protected] virtual~]# vim /etc/httpd/conf.d/nsd.conf
<VirtualHost *:80>
ServerName www0.example.com
DocumentRoot /var/www/virtual
</VirtualHost>
[[email protected] virtual~]# systemctl restart httpd
[[email protected] virtual~]# systemctl enable httpd
           

继续阅读