java 如何在Linux上升级Tomcat

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28378139/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 13:28:25  来源:igfitidea点击:

How to upgrade Tomcat on linux

javalinuxtomcatcentos

提问by Hyman

My current running Tomcat is as following

我目前运行的Tomcat如下

Tomcat Version : Apache Tomcat/5.5.36
Servlet Specification Version : 2.4
JSP version : 2.0

I need to change it to

我需要把它改成

Tomcat Version : Apache Tomcat/8.0.14
Servlet Specification Version : 3.1
JSP version : 2.3

I downloaded Tomcat version 8 and I have following, how can I run Tomcat 8 and make it default of the server?

我下载了 Tomcat 版本 8,我有以下内容,如何运行 Tomcat 8 并使其成为服务器的默认值?

root@server [/opt]# ls
./                           cpanel/                    pcre/
../                          curlssl/                   php_with_imap_client/
apache-tomcat-8.0.18/        jdk1.7.0_75/               suphp/
apache-tomcat-8.0.18.tar.gz  jdk-7u75-linux-x64.tar.gz  xml2/

I tried following command but it failed.

我尝试了以下命令,但失败了。

root@server [/opt/apache-tomcat-8.0.18/bin]# ./startup.sh
Cannot find apache-tomcat-8.0.18/bin/setclasspath.sh
This file is needed to run this program

~/.bashrc

~/.bashrc

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
JAVA_HOME="/usr/lib/jvm/jre-1.7.0-openjdk.x86_64"
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH

export CATALINA_HOME="apache-tomcat-8.0.18"

Java Version

爪哇版

java -version
java version "1.7.0_75"
OpenJDK Runtime Environment (rhel-2.5.4.0.el6_6-x86_64 u75-b13)
OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)
root@server [/opt/apache-tomcat-8.0.18/bin]# 

O/S

操作系统

Linux server.myproject.com 2.6.32-220.13.1.el6.x86_64 #1 SMP Tue Apr 17 
23:56:34 BST 2012 x86_64 x86_64 x86_64 GNU/Linux

回答by mysteryegg

The Tomcat startup.sh script uses $CATALINA_HOME to find setclasspath.sh, which is the cause of your failed startup. Therefore, $CATALINA_HOME needs to be an absolute path to your tomcat installation directory, e.g.

Tomcat startup.sh 脚本使用 $CATALINA_HOME 查找 setclasspath.sh,这是您启动失败的原因。因此,$CATALINA_HOME 需要是你的 tomcat 安装目录的绝对路径,例如

export CATALINA_HOME="/opt/apache-tomcat-8.0.18"

export CATALINA_HOME="/opt/apache-tomcat-8.0.18"

If you plan on upgrading again, you might consider setting $CATALINA_HOME to /opt/tomcat, then you would create a symbolic link from /opt/tomcat to /opt/apache-tomcat-8.0.18 or whatever future version you end up installing. Since you will likely have multiple environmental variables pointing to your tomcat directory, this gives you a single change point when updating references.

如果您打算再次升级,您可以考虑将 $CATALINA_HOME 设置为 /opt/tomcat,然后您将创建一个从 /opt/tomcat 到 /opt/apache-tomcat-8.0.18 或您最终安装的任何未来版本的符号链接. 由于您可能有多个环境变量指向您的 tomcat 目录,因此在更新引用时为您提供了一个更改点。

ln -nsf /opt/apache-tomcat-8.0.18 /opt/tomcat

ln -nsf /opt/apache-tomcat-8.0.18 /opt/tomcat