zoukankan      html  css  js  c++  java
  • apache 的虚拟主机和 web访问时序图

    一、提出问题:虚拟主机的配置

    http://localhost/news.html 
    http://www.sohu.com
    http://www.taobao.com.cn
    目前我们是 http://localhost/myblog/
    需求我希望
    http://www.shunping.com       http://www.sohu.com
     
    二、配置虚拟主机的步骤如下:
    1. 启用  httpd-vhosts.conf
    在 httpd.conf 文件中
    # Virtual hosts ,虚拟主机
    Include conf/extra/httpd-vhosts.conf   (代表连接到的文件位置)
    2.    在httpd-vhosts.conf文件中做配置 (文件连接过来配置内容)
    #配置我们自己的虚拟主机
    <VirtualHost 127.0.0.1:80>
        DocumentRoot "d:/myblog"
        #这里配置欢迎首页面
        DirectoryIndex index.html index.htm index.php
        <Directory />
        Options FollowSymLinks
        #不许可别人修改我们的页面
        AllowOverride None
        #设置访问权限
        Order allow,deny
        Allow from all
        </Directory>
    </VirtualHost>
    3. 修改hosts 文件 ->新的知识点. (重新审视我们的访问一个网页的真正流程)
    127.0.0.1            www.shunping.com
    53.jpg
            4.    测试一下
    三、课堂练习:
         
          在httpd.conf文件中配置一台www.sohu.cn的虚拟主机,然后在window系统中注册www.sohu.cn这台主机。
    • 1、在httpd.conf 文件中启用 httpd-vhosts.conf
    就是把#注销掉
    # Virtual hosts ,虚拟主机
    Include conf/extra/httpd-vhosts.conf
    • 2、假设我们的虚拟主机在 f:/myweb 盘 [该站点,事先有]
    • 3、设置http-vhosts.conf文件
    #配置我们自己的虚拟主机
    <VirtualHost127.0.0.1:80>
        DocumentRoot "d:/myblog"
        #这里配置欢迎首页面
        DirectoryIndex news.html  index.html index.htm index.php  (可以设置news.html为首页)
        <Directory />
        Options FollowSymLinks
        #不许可别人修改我们的页面
        AllowOverride None
        #设置访问权限
        Order allow,deny
        Allow from all
        </Directory>
    </VirtualHost>
            4、在hosts文件中添加我们的ip 和主机映射关系
    c:/windows/system32/drivers/etc/hosts
    127.0.0.1             www.sohu.cn
         
            5. 1  如果是配置多个站点通过端口来区分的话:需要  
                       在httpd-vhosts.conf文件中做配置多一次(不同端口)/hosts 文件修改多一次(复制多一份)/ httpd.conf文件中    多一个Linsten 端口号2
     
            5.2   如果是配置多个站点通过serverName来区分的话:需要  在httpd-vhosts.conf文件中修改如下:
    <VirtualHost  *:80>
        DocumentRoot "d:/myblog"
        ServerName www.daomul1.com
        DirectoryIndex news.html  index.html index.htm index.php  (可以设置news.html为首页)
        <Directory />
        Options FollowSymLinks
        #不许可别人修改我们的页面
        AllowOverride None
        #设置访问权限
        Order allow,deny
        Allow from all
        </Directory>
    </VirtualHost>
     
    <VirtualHost  *:80>
        DocumentRoot "d:/myblog"
        ServerName www.daomul2.com
        DirectoryIndex news.html  index.html index.htm index.php  (可以设置news.html为首页)
        <Directory />
        Options FollowSymLinks
        #不许可别人修改我们的页面
        AllowOverride None
        #设置访问权限
        Order allow,deny
        Allow from all
        </Directory>
    </VirtualHost>
        
  • 相关阅读:
    kernel 于ioctl申请书
    顺时针打印矩阵
    HDU 1557 权利指数 国家压缩 暴力
    从混沌到有序--熵
    分层思想总结
    什么是分层架构模式
    分层设计
    分层设计思想
    软件的生长方式
    设计模式、SOLID原则:组件与联系
  • 原文地址:https://www.cnblogs.com/daomul/p/3125461.html
Copyright © 2011-2022 走看看