• apache 虚拟主机配置(根据不同的域名映射到不同网站)


      最近弄了台香港服务器做测试,Web服务器软件用的是Apache2.2,机器只有一台,ip只有一个,但是想测试几个站点,于是尝试了下Apache的虚拟主机配置。之前已经写过一篇博文了——《Apache 根据不同的端口 映射不同的站点》,但是,今天在学习微信公众平台的时候,由于微信公众平台只支持80端口,所以无奈,只能尝试根据不同的域名映射不同的站点。

      

    一、修改httpd.conf

      打开Apache的目录,找到httpd.conf文件,分别去掉下面两行文字前面的#号。

     

     #LoadModule vhost_alias_module modules/mod_vhost_alias.s
     #Include conf/extra/httpd-vhosts.conf

    二、修改httpd-vhosts.conf

    打开该文件,看到以下类似内容。虚拟主机的配置也是参照以下内容配置。下面对该内容进行讲解

    <VirtualHost 59.188.244.204>
        ServerAdmin webmaster@dummy-host.www.ronghui66.com
        DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
        ServerName ronghui66.com:80
        
    <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs">
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.2/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks
    
        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
        #
        AllowOverride None
    
        #
        # Controls who can get stuff from this server.
        #
        Order allow,deny
        Allow from all
    
    </Directory>
        
    #    ServerAlias www.dummy-host.www.ronghui66.com
        ErrorLog "logs/bocai-error.log"
        CustomLog "logs/bocai-access.log" common
    </VirtualHost>
    
    
    #
    # VirtualHost example:
    # Almost any Apache directive may go into a VirtualHost container.
    # The first VirtualHost section is used for all requests that do not
    # match a ServerName or ServerAlias in any <VirtualHost> block.
    #
    <VirtualHost 59.188.244.204>
        ServerAdmin webmaster@dummy-host.www.ronghui66.com
        DocumentRoot "D:/wwwroot/weixin"
        ServerName 0735wmw.com:80
        
    <Directory "D:/wwwroot/weixin">
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.2/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks
    
        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
        #
        AllowOverride None
    
        #
        # Controls who can get stuff from this server.
        #
        Order allow,deny
        Allow from all
    
    </Directory>
        
    #    ServerAlias www.dummy-host.www.ronghui66.com
        ErrorLog "logs/weixin-error.log"
        CustomLog "logs/weixin-access.log" common
    </VirtualHost>

    ServerAdmin 管理员邮箱

    DocumentRoot 网站目录 (注意:如果网站目录中的路径有空格,请在路径两端加上双引号)

    ServerName 要绑定的域名(必填)

  • 相关阅读:
    剑指office--------重建二叉树
    剑指office--------二进制中1的个数
    剑指office--------最小的K个数 (待补充)
    剑指office--------二维数组的查找
    剑指office--------替换空格
    Redis集群
    一致性hash算法
    Zab协议(转)
    Redis线程模型
    Http Cookie和session
  • 原文地址:https://www.cnblogs.com/BTMaster/p/3583588.html
Copyright © 2020-2023  润新知