首页 > 代码库 > tomcat7 虚拟主机设置笔记

tomcat7 虚拟主机设置笔记

首页为二级目录访问,如:

http://www.abc.com:8080/training/


用户目录:/home/youway下创建目录:/home/youway/www/app1,在此目录下,放置web应用目录training,及index.html, 目录如下:

<html>
<head>
<meta http-equiv="Content-Language" content="utf-8">
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<meta http-equiv="refresh" content="0.1;url=http://www.abc.com:8080/training/">
<title></title>
</head>
<body>
</body>
</html>


修改$CATALINA_HOME/config/server.xml文件

<Engine name="Catalina" defaultHost="oa.gzdfbz.com">
 	  <Host name="oa.gzdfbz.com"  appBase="/home/youway/www/app1"
 	            unpackWARs="true" autoDeploy="true"
 	            xmlValidation="false" xmlNamespaceAware="false">
 	    <context path="/training/" docBase="/home/youway/www/app1" debug="0" reloadable="true"></context>
 	  </Host>
 	 
    </Engine>


在$CATALINA_HOME/conf/Catalina/www.abc.com 目录中,创建ROOT.xml文件,内容如下: 

<?xml version=‘1.0‘ encoding=‘utf-8‘?>
   <Context crossContext="true" docBase="/home/youway/www/app1" path="/training/" reloadable="true">
</Context>


参考链接:

http://tomcat.apache.org/tomcat-7.0-doc/virtual-hosting-howto.html


tomcat7 虚拟主机设置笔记