/ 中存储网

Apache2.2配置多个虚拟主机站点

2014-04-15 09:19:01 来源:kejihao
第一步:修改E:Program FilesApache2.2confhttpd.conf

--------------------注释掉一下内容-----------------

##DocumentRoot "E:/Program Files/Apache2.2/htdocs"

@注释中重点一(如果不注释以下内容,后面内容会有一些改变)

##<Directory />

##    Options FollowSymLinks

##    AllowOverride None

##    Order deny,allow

##    Deny from all

##</Directory>

##<Directory "E:/Program Files/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>

----------------------取消注释,释放以下内容---------------

Include conf/extra/httpd-vhosts.conf

第二步:修改E:Program FilesApache2.2confextrahttpd-vhosts.conf

----------------------取消注释,释放以下内容---------------

NameVirtualHost *:80

----------------------添加自己定义的域名虚拟主机---------------

<VirtualHost *:80>

ServerAdmin [email protected]

DocumentRoot "D:/www/test"

ServerName www.test1.com

ErrorLog "logs/www.test1.com-error_log"

CustomLog "logs/www.test1.com-access_log" common

</VirtualHost>

<VirtualHost *:80>

ServerAdmin [email protected]

DocumentRoot "D:/www/test"

ServerName www.test2.com

ErrorLog "logs/www.test2.com-error_log"

CustomLog "logs/www.test2.com-access_log" common

</VirtualHost>

@如果上面的“注释中重点一”中的内容没有注释掉,则需要为以上每个虚拟主机配置

<Directory "D:/www/test">(每个虚拟主机的路径不一样)

Options Indexes FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

否则不需要

第三步:修改C:WINDOWSsystem32driversetchosts

----------------------------增加以下内容-----------------------------

127.0.0.1       www.test2.com

127.0.0.2       www.test1.com

完成