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 要綁定的域名(必填)微信公衆平臺

相關文章
相關標籤/搜索