海草人  

你可以全用本地私有ip地址创建多个站点 127.0.0.x,这个网段的所有ip都是指向本机的,并且可以区分,这是计算机的私有ip地址,供测试用的,配置方法如下

 

一、打开httpd.conf

 

1、从ServerAdmin admin@localhost

    一直到:

    <IfModule dir_module>

        DirectoryIndex  index.html index.php  index.php3  index.htm

    </IfModule>

 

2、在D盘创建文件夹d:/website做为所有站点的父文件夹,以后的子站点全部放到这个文件夹内

 

3、将刚才找到的区域代码修改如下:

ServerAdmin admin@localhost

ServerName localhost:80

<Directory />

    Options FollowSymLinks

    AllowOverride All

    Order deny,allow

    Deny from all

</Directory>

 

<Directory "d:/website/">  

    Options Indexes FollowSymLinks

    AllowOverride all

    Order Deny,Allow

    Deny from all

    Allow from all

</Directory>

 

<IfModule dir_module>

    DirectoryIndex  index.html index.php  index.php3  index.htm

</IfModule>

#上面这句话是让apachewebsite及子文件夹有完全访问的权限,以后的站点全部放在该目录下

二、子站点配置方法


1、在httpd.conf文件中,找到 

 

  # Virtual hosts

  # Include conf/extra/httpd-vhosts.conf

   修改为

  # Virtual hosts

    Include d:/website/httpd-vhosts.conf

 

2.在 wamp/bin/apache/apache2.2.17/conf/extra/找到httpd-vhosts.conf文件,

  复制到:d:/website文件夹下

 

3.d:/website/创建子站点文件夹假如:d:/website/wwwroot1/

 

4.修改 d:/website/httpd-vhosts.conf 文件的内容

 

   <VirtualHost 127.0.0.2:80>

     DocumentRoot "d:/website/wwwroot1/"

     ServerName 127.0.0.2

  </VirtualHost>

 

5.保存httpd.conf,保存httpd-vhosts.conf,然后重启apache 服务

 

6.测试 在wwwroot1,下创建文件:index.php  用记事本来写入这些代码:

   <?php

phpinfo();

   ?>

 保存,然后打开浏览器,在地址栏里输入:http://127.0.0.2 会出现相关信息

 

7.建第二个站点,在website目录创建文件夹:d:/website/wwwroot2/


  打开文件:d:/website/httpd-vhosts.conf


  在追加站点配置代码如下:

  <VirtualHost 127.0.0.3:80>

     DocumentRoot "d:/website/wwwroot2/"

     ServerName 127.0.0.3

  </VirtualHost>

 

  根据第56步进行重启服务与测试


三、到hosts下将需要的ip修改为方便记忆输入的域名。

    hosts路径:C:\Windows\System32\drivers\etc

     127.0.0.2    localhost2

posted on 2016-02-17 15:11  海草人  阅读(203)  评论(0编辑  收藏  举报