实现一个 web 服务器

在 system1 上配置一个站点 http://system1.group8.example.com/,然后执行下述步骤:

1、从 http://server.group8.example.com/pub/system1.html 下载文件,并且将文件重名为 index.html 不要修改此文件的内容

2、将文件 index.html 拷贝到您的 web 服务器的 DocumentRoot 目录下

3、来自于 group8.example.com 域的客户端可以访问此web服务

4、来自于my133t.org域的客户端拒绝访问此web服务

  • 版本:Apache 2.4 +

答:

1、安装软件包

yum install httpd -y

2、建立配置文件

vim /etc/httpd/conf.d/httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "/var/www/html"
    ServerName system1.group8.example.com
    
    <Directory "/var/www/html">
        <RequireAll>
            Require all granted
            Require not host .my133t.org
        </RequireAll>
    </Directory>
</VirtualHost>
# 下载文件导致定目录内
wget -O /var/www/html/index.html http://server.group8.example.com/pub/system1.html

3、设置服务开机自启动并启动服务

systemctl enable httpd
systemctl start httpd

4、配置防火墙

firewall-cmd --permanent --add-service=http
firewall-cmd --reload

验证:再system2 上执行

curl system1.group8.example.com

更多详情:https://www.cnblogs.com/xiangsikai/p/9111688.html

原文地址:https://www.cnblogs.com/xiangsikai/p/10880229.html