tomcat多域名配置
2015-05-08 17:27
183 查看
1、找到你的tomcat然后在conf文件中找到server.xml打开;
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase"description="User
database that can be updated and saved"factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000"redirectPort="8443" />
<!--<Connector
port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<!-- <Cluster
className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- <Valve
className="org.apache.catalina.valves.RequestDumperValve"/>
-->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"xmlValidation="false" xmlNamespaceAware="false">
<!--<Valve
className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- <Valve
className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
-->
</Host>
</Engine>
</Service>
</Server>
在其中我主要是对俩个地方进行修改:
第一个将
<Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000"redirectPort="8443" />
修改为:
<Connector port="80" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000"redirectPort="8443" />
第二就是在中添加<host>(一个host代表一个域名或访问地址)
<Engine
name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"xmlValidation="false" xmlNamespaceAware="false" />
</Engine>
修改为
<Engine
name="Catalina" defaultHost=www.abc.com>
<Host name="www.coe.com" appBase="webapps" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false" >
<Context path="" docbase="D:\Tomcat
6.0\webapps\ROOT" crosscontext="true" />
</Host>
<Host name="www.abc.com" appBase="ccc" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false" >
<Context path="" docbase="D:\Tomcat
6.0\ccc\ROOT" crosscontext="true" />
</Host>
<Host name=www.cba.com appBase="[b]dddd[/b]" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false" />
<Context path="" docbase="D:\Tomcat
6.0\dddd\ROOT" crosscontext="true" />
</Host>
</Engine>
tomcat 目录配置如下图:
![](http://s15.sinaimg.cn/middle/6341fc0fh94eab9edd21e&690)
其中ccc和dddd都是一个单独的项目,而每一个项目都必须放在root文件夹中才能实现多域名的访问。
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase"description="User
database that can be updated and saved"factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000"redirectPort="8443" />
<!--<Connector
port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<!-- <Cluster
className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- <Valve
className="org.apache.catalina.valves.RequestDumperValve"/>
-->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"xmlValidation="false" xmlNamespaceAware="false">
<!--<Valve
className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- <Valve
className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
-->
</Host>
</Engine>
</Service>
</Server>
在其中我主要是对俩个地方进行修改:
第一个将
<Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000"redirectPort="8443" />
修改为:
<Connector port="80" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000"redirectPort="8443" />
第二就是在中添加<host>(一个host代表一个域名或访问地址)
<Engine
name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"xmlValidation="false" xmlNamespaceAware="false" />
</Engine>
修改为
<Engine
name="Catalina" defaultHost=www.abc.com>
<Host name="www.coe.com" appBase="webapps" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false" >
<Context path="" docbase="D:\Tomcat
6.0\webapps\ROOT" crosscontext="true" />
</Host>
<Host name="www.abc.com" appBase="ccc" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false" >
<Context path="" docbase="D:\Tomcat
6.0\ccc\ROOT" crosscontext="true" />
</Host>
<Host name=www.cba.com appBase="[b]dddd[/b]" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false" />
<Context path="" docbase="D:\Tomcat
6.0\dddd\ROOT" crosscontext="true" />
</Host>
</Engine>
tomcat 目录配置如下图:
其中ccc和dddd都是一个单独的项目,而每一个项目都必须放在root文件夹中才能实现多域名的访问。
相关文章推荐
- 使用Tomcat配置域名---之详细篇
- TOMCAT服务器配置域名
- Tomcat多域名配置
- Tomcat配置域名
- 使用Tomcat配置域名
- Tomcat服务器配置,二级域名,域名访问
- 在本机利用Tomcat配置多重域名的方法
- Tomcat 下配置一个ip绑定多个域名
- tomcat绑定二级域名 配置
- Tomcat6 配置多虚拟主机,多域名绑定一IP
- tomcat配置多域名访问(server.xml)
- tomcat 配置域名与工程映射
- 配置apache + tomcat 并设置apache 二级域名重定向试验
- tomcat多域名配置
- tomcat配置只能用域名访问,禁止用ip访问
- tomcat多域名配置
- tomcat虚拟目录及域名配置
- Tomcat6配置详解(虚拟目录+多域名绑定)
- Apache Http server +tomcat 实现域名重写配置
- 一个Tomcat支持不同的域名访问各自不同程序的配置方法实践