tomcat修改项目根目录

来源:互联网 发布:实况足球2017捏脸数据 编辑:程序博客网 时间:2024/05/16 15:20

今天做nginx转发tomcat,遇到了这个问题:

nginx无法转发到tomcat,跟路径始终是ROOT郁闷啊,

 

你要是直接找解决方法的,方法是

修改appBase路径为绝对路径,不使用相对路径

 

<Host name="a"  appBase="/usr/apache-tomcat-7.0.50-wxser/webapps"            unpackWARs="true" autoDeploy="true"><Context path="" docBase="wxserver" debug="true" reloadable="true" />        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"               prefix="wxser_access_log." suffix=".txt"               pattern="%h %l %u %t &quot;%r&quot; %s %b" /></Host>

 

按照上面的方式该就行了。为了迅速下面的东西可以略过

 

说下具体情况:

第一个遇到但是是502网关错误,这个和明显不是tomcat修改更路径的问题 ,后来发现是nginx配置文件里有个错误配置,换机器继续

 

第二个配置好nginx和tomcat的的根目录以及域名解析,访问通过,可以出现的是tomcat管理页面,这个很是头疼。为什么这么说,应为我是完全按照之前配置通过的步骤和方法配置的。

基本上处理IP,端口,项目名称,之外完全一样

噢 对了,tomcat小版本不一样,之前成功的是7.0.50 现在的是7.0.55,这到底是什么原因 ??

 

然后各种百度,google,最终几乎所有的链接都显示一个内容 

1.修改host里面的appBase,

2.然后在host结束标签之前添加context标签 

3.修改上面添加的context里面的docBase

 

对这个流程没错,我也是按照这个流程走的,这是为什么呢 ? 

 

我的配置 如下:

<Host name="a"  appBase="webapps"            unpackWARs="true" autoDeploy="true"><Context path="" docBase="wxserver" debug="true" reloadable="true" />        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"               prefix="wxser_access_log." suffix=".txt"               pattern="%h %l %u %t &quot;%r&quot; %s %b" /></Host>

 

细心的话你可以看到我的appBase是相对路径,而想下面两个连接中的都是绝对路径 

http://yuhongchun.blog.51cto.com/1604432/544659

http://xinying.blog.51cto.com/441770/367863

 

在tomcat自带的文档里有这么一段说明 

 

AttributeDescriptionappBase

The Application Base directory for this virtual host. This is the pathname of a directory that may contain web applications to be deployed on this virtual host. You may specify an absolute pathname, or a pathname that is relative to the $CATALINA_BASE directory. See Automatic Application Deployment for more information on automatic recognition and deployment of web applications. If not specified, the default of webapps will be used.

 

你可以用绝对路径也可以用一个相对路径,相对于CATALINA_BASE的路径,

这么说其实我配置的webapps应该是对的,并且我之前也是这么配置的,但是为什么就不行呢 ,好纠结啊。

 

试了一下绝对路径,成功了,不知道原因,

 

我系统里面有多个tomcat,不知道是不是这个原因,

有高手知道的,指点一下

 

昨天更新了下项目,发现有有问题了,

最后把docBase也改成绝对路径才得以解决 

 

 

 

 

0 0
原创粉丝点击