在Ubuntu上安装Tomcat 6

If you are running Ubuntu and want to use the Tomcat servlet container, you should not use the version from the repositories as it just doesn’t work correctly. Instead you’ll need to use the manual installation process that I’m outlining here.

如果您正在运行Ubuntu,并且想使用Tomcat Servlet容器,则不应使用存储库中的版本,因为它无法正常工作。 相反,您将需要使用我在此处概述的手动安装过程。

Before you install Tomcat you’ll want to make sure that you’ve installed Java. I would assume if you are trying to install Tomcat you’ve already installed java, but if you aren’t sure you can check with the dpkg command like so:

在安装Tomcat之前,您需要确保已安装Java。 我假设如果您尝试安装Tomcat,那么您已经安装了Java,但是如果不确定,可以使用dpkg命令进行检查,如下所示:

dpkg –get-selections | grep sun-java

dpkg –获取选择| grep sun-java

This should give you this output if you already installed java:

如果您已经安装了java,这应该给您以下输出:

sun-java6-bin                                   install
sun-java6-jdk                                   install
sun-java6-jre                                   install

sun-java6-bin                                   install
sun-java6-jdk                                   install
sun-java6-jre                                   install

If that command has no results, you’ll want to install the latest version with this command:

如果该命令没有结果,则需要使用此命令安装最新版本:

sudo apt-get install sun-java6-jdk

须藤apt-get install sun-java6-jdk

Installation

安装

Now we’ll download and extract Tomcat from the apache site. You should check to make sure there’s not another version and adjust accordingly.

现在,我们将从apache站点下载并提取Tomcat。 您应该检查以确保没有其他版本,并进行相应调整。

wget http://apache.hoxt.com/tomcat/tomcat-6/v6.0.14/bin/apache-tomcat-6.0.14.tar.gz

wget http://apache.hoxt.com/tomcat/tomcat-6/v6.0.14/bin/apache-tomcat-6.0.14.tar.gz

tar xvzf apache-tomcat-6.0.14.tar.gz

焦油xvzf apache-tomcat-6.0.14.tar.gz

The best thing to do is move the tomcat folder to a permanent location. I chose /usr/local/tomcat, but you could move it somewhere else if you wanted to.

最好的办法是将tomcat文件夹移动到一个永久位置。 我选择了/ usr / local / tomcat,但如果愿意,可以将其移至其他位置。

sudo mv apache-tomcat-6.0.14 /usr/local/tomcat

sudo mv apache-tomcat-6.0.14 / usr / local / tomcat

Tomcat requires setting the JAVA_HOME variable. The best way to do this is to set it in your .bashrc file. You could also edit your startup.sh file if you so chose.

Tomcat需要设置JAVA_HOME变量。 最好的方法是在.bashrc文件中进行设置。 您也可以选择编辑startup.sh文件。

The better method is editing your .bashrc file and adding the bolded line there. You’ll have to logout of the shell for the change to take effect.

更好的方法是编辑.bashrc文件并在其中添加粗体行。 您必须注销Shell才能使更改生效。

vi ~/.bashrc

vi〜/ .bashrc

Add the following line:

添加以下行:

export JAVA_HOME=/usr/lib/jvm/java-6-sun

导出JAVA_HOME = / usr / lib / jvm / java-6-sun

At this point you can start tomcat by just executing the startup.sh script in the tomcat/bin folder.

此时,您只需执行tomcat / bin文件夹中的startup.sh脚本即可启动tomcat。

Automatic Starting

自动启动

To make tomcat automatically start when we boot up the computer, you can add a script to make it auto-start and shutdown.

要使tomcat在启动计算机时自动启动,可以添加脚本使其自动启动和关闭。

sudo vi /etc/init.d/tomcat

须藤vi /etc/init.d/tomcat

Now paste in the following:

现在粘贴以下内容:

# Tomcat auto-start## description: Auto-starts tomcat# processname: tomcat# pidfile: /var/run/tomcat.pid

#Tomcat自动启动##描述:自动启动tomcat#进程名:tomcat#pidfile:/var/run/tomcat.pid

export JAVA_HOME=/usr/lib/jvm/java-6-sun

导出JAVA_HOME = / usr / lib / jvm / java-6-sun

case $1 instart)        sh /usr/local/tomcat/bin/startup.sh        ;; stop)           sh /usr/local/tomcat/bin/shutdown.sh        ;; restart)        sh /usr/local/tomcat/bin/shutdown.sh        sh /usr/local/tomcat/bin/startup.sh        ;; esac    exit 0

案例$ 1 instart)sh /usr/local/tomcat/bin/startup.sh ;; 停止)sh /usr/local/tomcat/bin/shutdown.sh ;; 重新启动)sh /usr/local/tomcat/bin/shutdown.sh sh /usr/local/tomcat/bin/startup.sh ;; esac出口0

You’ll need to make the script executable by running the chmod command:

您需要通过运行chmod命令使脚本可执行:

sudo chmod 755 /etc/init.d/tomcat

须藤chmod 755 /etc/init.d/tomcat

The last step is actually linking this script to the startup folders with a symbolic link. Execute these two commands and we should be on our way.

最后一步实际上是使用符号链接将此脚本链接到启动文件夹。 执行这两个命令,我们就该走了。

sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcatsudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat

sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcatsudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat

Tomcat should now be fully installed and operational. Enjoy!

Tomcat现在应该已完全安装并可以运行。 请享用!

翻译自: https://www.howtogeek.com/howto/linux/installing-tomcat-6-on-ubuntu/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值