测试环境 win 7 ,apache 2.2安装版
1、安装完 apache 后
2、用记事本打开apache安装目录conf目录httpd.conf文件
3、找到如下代码:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
将 Deny from all 改成 allow from all,最终是
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
allow from all
</Directory>
4、找到如下代码 :#Include conf/extra/httpd-vhosts.conf ,将第一个#号去掉保存,把文件关闭
5、用记事本打开apache安装目录下的 conf/extra/httpd-vhosts.conf 文件
6、在最后加上:
<VirtualHost 127.0.0.2>
DocumentRoot "F:\wwwroot\struts2"
</VirtualHost>
<VirtualHost 127.0.0.3>
DocumentRoot "F:\wwwroot\spring3"
</VirtualHost>
F:\wwwroot\struts2、F:\wwwroot\spring3 是我的网站根目录,把其改成自己网站根目录即可
7、保存文件,重启apache服务
8、打开浏览器可以访问127.0.0.1 这是apache默认的网站,127.0.0.2、127.0.0.3是我自己配置的网站
OK,大功告成