当前位置: 首页>>技术教程>>正文


apt – 如何在 Ubuntu 12.04.3 LTS 上安装 Tomcat 7.0.42?

, , , ,

问题描述

系统管理员给了我一个我通过终端访问的虚拟机。

我有 root 访问权限,它有 Ubuntu 12.04.3 LTS。

命令 apt-cache policy tomcat7 通知:

tomcat7:
  Installed: (none)
  Candidate: 7.0.26-1ubuntu1.2
  Version table:
     7.0.26-1ubuntu1.2 0
        500 http://br.archive.ubuntu.com/ubuntu/ precise-updates/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ precise-security/universe amd64 Packages
     7.0.26-1ubuntu1 0
        500 http://br.archive.ubuntu.com/ubuntu/ precise/universe amd64 Packages
root@mymachine:~#

但是,我想在上面安装最新的 Tomcat 7 (7.0.42)。

可行吗?如果是,如何?

最佳办法

是的,可以安装 Tomcat 7.0.42,但您必须安装 “manually”。以下是有关如何安装的步骤:

\\n

Note: visit this question if you want to know why it’s not in the repositories: Why don’t the Ubuntu repositories have the latest versions of software?

\\n

Prerequisite: you need to have Java installed, and we need its\\n path. Java is usually installed under /usr/lib/jvm. Once you have\\n installed Java, you can run the command update-alternatives --config\\n java to show you the exact path; look at the first entry (the one\\n with a * next to it. You can hit Enter to exit this\\n screen). We only need the directory after /jvm/. On my machine, the\\n directory was /usr/lib/jvm/java-7-openjdk-i386/. This answer will\\n assume that this is the Java directory, but you should change the\\n commands accordingly.

\\n

  1. wget http://mirror.atlanticmetro.net/apache/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz \n

    • 这会将 Tomcat 7.0.42 下载到您的当前目录。

  2. tar xzvf apache-tomcat-7.0.42.tar.gz \n

    • 这将提取文件。

  3. sudo mv apache-tomcat-7.0.42 /usr/local \n

    • 这会将 Tomcat 移动到 /usr/local 。你可以选择任何你想要的路径。其余命令将假定您已使用此路径。

  4. nano ~/.bashrc – 这将打开一个文本编辑器。转到文件末尾( Alt + / )并添加以下两行:\n\nexport CATALINA_HOME=/usr/local/apache-tomcat-7.0.42\nexport JAVA_HOME=/usr/lib/jvm/java-7- openjdk-i386/\n\n\n记住:这是我的 Java 的路径。将其更改为您安装的 Java。\n

  5. . ~/.bashrc \n

    • 这将应用我们所做的更改。

  6. sudo $CATALINA_HOME/bin/startup.sh – 你应该会看到如下内容:\n\n使用 CATALINA_BASE:/usr/local/apache-tomcat-7.0.42\n使用 CATALINA_HOME:/usr/local/apache-tomcat-7.0.42\n使用 CATALINA_TMPDIR:/usr/local/apache-tomcat- 7.0.42/temp\n使用 JRE_HOME: /usr\n使用 CLASSPATH: /usr/local/apache-tomcat-7.0.42/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.42/bin/tomcat-juli.jar\n \n并且没有错误。

你完成了。将浏览器指向 http://localhost:8080,您应该会看到 Tomcat 页面:

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/13031.html,未经允许,请勿转载。