http虚拟主机的简单配置训练

http的虚拟主机
对于某些web访问站点而言,每天的访问量很少,因此真正的放一台服务器去进行web站点是很
浪费资源的,因此我们选择了虚拟主机
web处理模块的分类(MPM)
1.perfork
一个请求占用一个进程
2.worker
一个请求占用一个线程
3.event(httpd2.2暂时不支持httpd2.4默认的就是event)
事件驱动模型,通知

我们都知道,无论是虚拟的还是物理的主机,我们都需要去辨识这台主机,辨识的方法有三种
1.基于ip
2.基于端口
3.基于域名

以下例子就是对于以上三种的配置练习:
-----------------------------------------------------------------------------------------------------------
NameVirtualHost 192.168.192.130:80

        ServerName hello2.magedu.com
        DocumentRoot "/www/magedu2.com"
        CustomLog "/var/log/httpd/magedu2.com/access_log" combined
       < Directory "/www/magedu2.com">
                Options none
                AllowOverride AuthConfig
                AuthType Basic
                AuthName        "My name."
                AuthUserFile "/etc/httpd/conf/htpasswd"
                Require valid-user
       < /Directory>   
< /VirtualHost>

        Servername hello.magedu.com
        DocumentRoot "/www/magedu.com"
        CustomLog  "/var/log/httpd/magedu.com/access_log" combined
< /VirtualHost>
 
 

        ServerName www.a.org
        DocumentRoot "/www/a.org"  
        CustomLog "/var/log/httpd/a.org/access_log" combined
< /VirtualHost>
 

        ServerName www.b.org
        DocumentRoot    "/www/b.org"
       < Directory "/www/b.org">
                Options none
                AllowOverride none
              Order deny,allow
                      deny from 192.168.192.131
       < /Directory>
< /VirtualHost>
 
原文地址:https://www.cnblogs.com/huwentao/p/6999178.html