利用tomcat配置网站

1: 首先将tomcat考到C盘;

 

利用tomcat配置网站_第1张图片

 

2:建立我们存放web应用的目录,我建立在D:\myWeb  ,然后将自己的web应用考到myWeb目录下:

 

利用tomcat配置网站_第2张图片

 

3:wApp的目录结构为:

 

利用tomcat配置网站_第3张图片

WEB-INF: 结构:

利用tomcat配置网站_第4张图片

web.xml:  配置默认的主页:

<?xml version="1.0" encoding="ISO-8859-1"?>
<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"> 
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

</web-app>

  

4:在C:\apache-tomcat-7.0.5\conf  中配置server.xml

 

  <Host name="www.gbx.com"  appBase="D:\myWeb">
	<Context path="" docBase="D:\myWeb\wApp" />
      </Host>

  

5: 由于我们的网站没有在DNS注册,所以只能修改Windows里面的配置:

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

 

利用tomcat配置网站_第5张图片

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost
192.168.1.104 www.gbx.com

  

6: 此时在浏览器里面只要我们键入:http://www.gbx.com/   就会访问到我们配置的主页了

 

 

 

 

你可能感兴趣的:(tomcat)