Tomcat下配置多服务以适应不同项目(修改版)

最近为公司的一个产品开发了个回访平台,部署的时候遇到了点小问题,由于我做的这个项目是部署在webapps的ROOT根目录下的。由于有一个项目已经占据了根目录的位置,所以得想办法解决。想到Tomcat下可以配置多个不同的服务以适应不同项目的需要,所以配置了一下,解决了这个问题。现在分享一下,大家互相探讨。
要配置多服务,就要更改server.xml文件,要在这个文件的</Service>下面加上如下内容

<Service name="MyCatalina">

<Connector port="8081" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" />

<Connector port="8010" enableLookups="false" redirectPort="8444" protocol="AJP/1.3" />

<Engine name="MyCatalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>

<Host name="localhost" appBase="e:\portalcrm"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>

</Engine>

</Service>

这个服务就配置好了,把端口号换了就可以了。接下来要在conf文件夹下建立MyCatalina文件夹,里面保持跟Catalina一样的内容就可以。
然后在你E盘的portalcrm文件夹下建立ROOT目录,将你的项目文件拷贝进去就可以了。

在浏览器上访问http://xxx.xxx.xx.xx:8081/xxx/xxx/xxx.do
ok,发现页面了吧,指向成功。

[color=red]感谢1L和2L的两位朋友。虽然我服务器上没有做域名解析,不过这样的方法显然更好。[/color]
到C:\WINDOWS\system32\drivers\etc\目录下,找到host文件,打开,稍作修改内容如下

# copyright (c) 1993-1999 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
127.0.0.1 localhost
192.168.1.88 www.portalcrm.com

最后一行是我做的指向,不过目前域名还没有解析,只是我本机的内网IP。
然后修改下server.xml文件,在</Engine>前添加如下内容

<Host name="kefu.58.com.cn" appBase="/opt/portalcrm/ROOT" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="/opt/portalcrm/ROOT" path="/" reloadable="true" ></Context>
</Host>


这样就成功了,我只要访问
http://www.portalcrm.com:8080/xxx/xxx/xx.do就ok了。
欢迎大家继续拍砖,交流学习。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值