apache部署WEB项目(配置多个地址)

1、新建目录D:\Apache22\Webapps,作为web项目目录
   新建目录D:\Apache22\Webapps100,作为web项目目录
2、在httpd.conf 最后加上
<VirtualHost 127.0.0.1:80>
DocumentRoot D:\Apache22\Webapps
ServerName 127.0.0.1:80
<VirtualHost>

<VirtualHost 127.0.0.100:80>
DocumentRoot D:\Apache22\Webapps100
ServerName 127.0.0.100:80
<VirtualHost>

3、重启 apache D:\Apache22\bin>httpd.exe -k start

4、打开浏览器 http://127.0.0.1/

显示
Forbidden
You don't have permission to access / on this server.
5、打开浏览器 http://127.0.0.100/

显示
Forbidden
You don't have permission to access / on this server.

6、配置目录访问权限

<Directory "D:\Apache22\Webapps" />
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order Allow,Deny
Allow from all

</Directory>

<Directory "D:\Apache22\Webapps100"/>
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>

7.重启apache

报错
Syntax error on line 194 of D:/Apache22/conf/httpd.conf:
Multiple <Directory> arguments not (yet) supported.

8、重新配置

<Directory "/Apache22/Webapps100">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>

 

<Directory "/Apache22/Webapps">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order Allow,Deny
Allow from all

</Directory>
9.启动成功
 
http://127.0.0.1/  显示 Index of /

http://127.0.0.100/  显示 Index of /

10.分别建立测试页面放入不同目录

100test.html 放入 D:\Apache22\Webapps100

1test.html 放入 D:\Apache22\Webapps

11、打开页面 测试成功

http://127.0.0.100/100test.html 显示 100 测试成功127.0.0.100

http://127.0.0.1/1test.html 显示 测试成功127.0.0.1