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

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

  

1、修改httpd.conf

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

 

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

2、修改httpd-vhosts.conf

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

<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 要绑定的域名(必填)微信公众平台

相关文章
相关标签/搜索