windows下apache配置多个站点

Apache的WEB服务器仅有一个ip ,却需要服务多个域名(实际是多个网站的服务)。怎么配置呢:

1:确保站点80端口开放。

# Ensure that Apache listens on port 80
Listen 80


# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80


2:httpd.conf修改。

# Virtual hosts
Include conf/extra/httpd-vhosts.conf  去掉前面的注释


3:修改 apache2.2.23\conf\extra下的 httpd-vhosts.conf


NameVirtualHost *:80


#
# 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 *:80>
    ServerAdmin [email protected]
    DocumentRoot "d:/mywork/tg"

    ServerName tg.zg.com
    <Directory "d:/mywork/tg">    // 这里是项目的目录
           Options Indexes FollowSymLinks
           AllowOverride all
           Order Deny,Allow
           Deny from all
           Allow from 127.0.0.1   
   </Directory>
</VirtualHost>


<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "d:/mywork/zg"

    ServerName www.zays.com
    <Directory "d:/mywork/zg">    // 这里是项目的目录
           Options Indexes FollowSymLinks
           AllowOverride all
           Order Deny,Allow
           #Deny from all
           Allow from 127.0.0.1   
   </Directory>
</VirtualHost>


<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "d:/mywork/test"

    ServerName test.zg.com
    <Directory "d:/mywork/test">    // 这里是项目的目录
           Options Indexes FollowSymLinks
           AllowOverride all
           Order Deny,Allow
           #Deny from all
           Allow from 127.0.0.1   
   </Directory>
</VirtualHost>


4:windows/system/etc/driver/hosts下

127.0.0.1  test.zg.com

127.0.0.1  tg.zg.com

127.0.0.1  test.zg.com


5:httpd.conf下的  

   类似 这样的<Directory "d:/mywork"></Directory>可以全部注释掉


重启apache服务,应该可以了。

  


你可能感兴趣的:(apache,windows)