• 提供的默认配置
    Listen:监听地址:端口(80)
    ServerName:本站点注册的DNS名称(空缺)
    DocumentRoot:网页根目录(/var/www/html)
    – DirectoryIndex:起始页/首页文件名(index.html)

    主配置文件:/etc/httpd/conf/httpd.conf

    基于网页文件目录,进行访问控制

    Require all denied #拒绝所有人访问


    Require all granted #允许所有人访问

    http://192.168.4.7= DocumentRoot 设置路径

    二、虚拟Web主机
    – 由同一台服务器提供多个不同的Web站点

    • 区分方式
    – 基于域名的虚拟主机
    – 基于端口的虚拟主机
    – 基于IP地址的虚拟主机
    • 配置文件路径
    – /etc/httpd/conf/httpd.conf #主配置文件
    – /etc/httpd/conf.d/.conf #调用配置文件
    为每个虚拟站点添加配置

    ServerName 此站点的DNS名称
    DocumentRoot 此站点的网页根目录

    • 采用/etc/hosts文件直接解析域名,*只为本机解析

    • 一旦使用虚拟Web主机功能,所有的网站都必须使用虚拟Web进行呈现
    systemctl restart httpd

    • l基于端口的虚拟Web主机
    [root@svr7 ~]# vim /etc/httpd/conf.d/haha.conf

    ServerName www.qq.com
    DocumentRoot /var/www/qq

    Listen 8080

    ServerName www.qq.com
    DocumentRoot /var/www/lol

    ]# systemctl restart rpcbind #涉及动态端口,nfs-server依赖此服务
    ]# systemctl restart nfs-server