tomcat多域名配置
2016-05-17 16:32
489 查看
1、找到你的tomcat然后在conf文件中找到server.xml打开;
<Serverport="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 andsaved"factory="org.apache.catalina.users.MemoryUserDatabaseFactory"pathname="conf/tomcat-users.xml"/>
</GlobalNamingResources>
<Servicename="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"/>
<Enginename="Catalina"
defaultHost="localhost">
<!-- <ClusterclassName="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!--<ValveclassName="org.apache.catalina.valves.RequestDumperValve"/>
-->
<Realm
className="org.apache.catalina.realm.UserDatabaseRealm"resourceName="UserDatabase"/>
<Hostname="localhost"
appBase="webapps"
unpackWARs="true"
autoDeploy="true"
xmlValidation="false"
xmlNamespaceAware="false">
<!--<ValveclassName="org.apache.catalina.authenticator.SingleSignOn"/>
-->
<!--<ValveclassName="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"
bc95
xmlValidation="false"
xmlNamespaceAware="false" >
<Contextpath=""docbase="D:\Tomcat6.0\webapps\ROOT"crosscontext="true"/>
</Host>
<Host
name="www.abc[b].com[/b]"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"/>
<Contextpath=""docbase="D:\Tomcat6.0\dddd\ROOT"crosscontext="true"/>
</Host>
</Engine>
其中ccc和dddd都是一个单独的项目,而每一个项目都必须放在root文件夹中才能实现多域名的访问。
<Serverport="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 andsaved"factory="org.apache.catalina.users.MemoryUserDatabaseFactory"pathname="conf/tomcat-users.xml"/>
</GlobalNamingResources>
<Servicename="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"/>
<Enginename="Catalina"
defaultHost="localhost">
<!-- <ClusterclassName="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!--<ValveclassName="org.apache.catalina.valves.RequestDumperValve"/>
-->
<Realm
className="org.apache.catalina.realm.UserDatabaseRealm"resourceName="UserDatabase"/>
<Hostname="localhost"
appBase="webapps"
unpackWARs="true"
autoDeploy="true"
xmlValidation="false"
xmlNamespaceAware="false">
<!--<ValveclassName="org.apache.catalina.authenticator.SingleSignOn"/>
-->
<!--<ValveclassName="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"
bc95
xmlValidation="false"
xmlNamespaceAware="false" >
<Contextpath=""docbase="D:\Tomcat6.0\webapps\ROOT"crosscontext="true"/>
</Host>
<Host
name="www.abc[b].com[/b]"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"/>
<Contextpath=""docbase="D:\Tomcat6.0\dddd\ROOT"crosscontext="true"/>
</Host>
</Engine>
其中ccc和dddd都是一个单独的项目,而每一个项目都必须放在root文件夹中才能实现多域名的访问。
相关文章推荐
- java对世界各个时区(TimeZone)的通用转换处理方法(转载)
- java-注解annotation
- java-模拟tomcat服务器
- java-用HttpURLConnection发送Http请求.
- java-WEB中的监听器Lisener
- Android IPC进程间通讯机制
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- 介绍一款信息管理系统的开源框架---jeecg
- 聚类算法之kmeans算法java版本
- java实现 PageRank算法
- PropertyChangeListener简单理解
- c++11 + SDL2 + ffmpeg +OpenAL + java = Android播放器
- 插入排序
- 冒泡排序
- 堆排序
- 快速排序
- 二叉查找树