在阿里云做好域名的配置和地址解析后,需要在服务器上的tomcat的conf文件下的server.xml的文件中作如下改动
1,如果有要求,可以将Engine的defaultHost该成你想要的域名,一般为默认的localHost
2,将host name 修改为在阿里云上的域名(也可改成localhost,改成这个,打开运行项目就要写本地的地址即 127.0.0.1:端口号/项目名 或者 外网地址:端口号/项目名)
3,appBase 一般默认为tomcat放项目的外面的那个文件名
4,docBase 一般为项目名,也有例子会将其写成为项目的绝对路径,这样写可以但是不严谨,最好只写项目名即可
5, <Context > 里可以配置项目的具体配置,有几个项目就配几个context,也有例子说有几个项目就配几个host,但是这样其实并不简便,多配个context,但是如果在有多个域名,每个域名对应一个不同的项目,则可配置多个host,配context只是对应一个域名,用path来区别打开不同的项目
6,path为打开项目的地址的附加地址,一般都是地址加端口号加项目名,如果像在此处有指向的配置好的域名地址,打开域名地址即可,如果在path里配地址,即打开项目的路径就会改编为域名加path里的路径,,这样配置可以区别多个项目(不同的项目不同的打开路径,就像这里的第一个项目,打开路径是域名,第二个项目的打开路径是域名/manage,
<Engine name="Catalina" defaultHost="www.X.com">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- The request dumper valve dumps useful debugging information about
the request and response data received and sent by Tomcat.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="www.X.com" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="ideassoft" path="" reloadable="true"/>
<Context docBase="manage" path="/manage" reloadable="true"/>
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
-->
</Host>
</Engine>
以下为我自己在找着正确的做法前,尝试的几个做法
1,配置多个·host,docBase 为项目的绝对路径
<Engine name="Catalina" defaultHost="localhost">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- The request dumper valve dumps useful debugging information about
the request and response data received and sent by Tomcat.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false" >
<Context path="" docbase="D:\apache-tomcat-6.0.39\webapps\manage" crosscontext="true" />
</Host>
<Host name="www.X.com" appBase="webapps" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false" >
<Context path="" docbase="D:\apache-tomcat-6.0.39\webapps\X" crosscontext="true" />
</Host>
</Engine>
2,配置多个service
这里就不做解释了,因为这个方法不太建议使用