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 [email protected] 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 [email protected] 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 要绑定的域名(必填)
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。