您的位置:首页 > 数据库 > Oracle

java+oracle+web(第六天) tomcat介绍 (三)建立虚拟目录

2015-05-13 21:31 447 查看

20150513配置虚拟主机

IE访问流程



配置我的虚拟主机地址是:http://
www.igo.com

在我的主机IE里面输入http://
www.igo.com:8080 就可以直接访问到我的IGO首页。

详细步骤如下

1、 修改我的host文件:文件位置:C:\Windows\System32\drivers\etc\ hosts ,最后添加内容:

127.0.0.1 www.igo.com

保存文件。

2、 G:\JavaSoft\web\igo新建一个目录igo目录,igo下面新建立其他的各个模块,

新建立一个igoindex目录,然后在igoindex中建立index.jsp 首页。

3、 修改 tomcat的server.xml文件,添加host节点,配置虚拟主机的地址和web映射目录

<!-- ADD igo by me -->

<Host name="www.igo.com" appBase="G:\JavaSoft\web\igo\igoindex"

unpackWARs="true"autoDeploy="true">

<!--Contextpaht = "" 表示设置首页-->

<Context path= "" docBase= "G:\JavaSoft\web\igo\igoindex" reloadable= "ture"/>

<ValveclassName="org.apache.catalina.valves.AccessLogValve"directory="logs"

prefix="localhost_access_log." suffix=".txt"

pattern="%h %l %u %t"%r" %s %b" />

</Host>

<!--ADD igo END-->

4、 在 igo目录下建立WEB-INF文件夹和web.xml文件

从别的xml文件中拷贝数据,并修改,最后如下:

<?xml version="1.0"encoding="gb2312"?>

<web-app

xmlns="http://java.sun.com/xml/ns/javaee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"

metadata-complete="true"

<welcome-file-list>

<welcome-file>index.html</welcome-file>

<welcome-file>index.xhtml</welcome-file>

<welcome-file>index.htm</welcome-file>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

</web-app>

5、 重启tomcat

6、 www.igo.com:8080就可以访问到主页了。

相关目录结构以及效果图如下:



9: 讲server.xml文件的端口配置成80后,就可以直接输入www.igo.com进行访问了。

<Connector port="80" protocol="HTTP/1.1"

connectionTimeout="20000"

redirectPort="8443" />
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: