首页 > Web开发 > 详细

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

时间:2014-03-06 10:51:54      阅读:572      评论:0      收藏:0      [点我收藏+]

  最近弄了台香港服务器做测试,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

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

bubuko.com,布布扣
<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>
bubuko.com,布布扣

ServerAdmin 管理员邮箱

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

ServerName 要绑定的域名(必填)

apache 虚拟主机配置(根据不同的域名映射到不同网站),布布扣,bubuko.com

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

原文:http://www.cnblogs.com/BTMaster/p/3583588.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!