Tomcat指南(二)第一章Getting Started with Tomcat

Because Tomcat is written in Java, some people assume that you have to be a Java guru to use it. That is not so! Although you need to know Java to modify the inter- nals of Tomcat or to write your own servlet programs, you do not need to know any Java to use Tomcat or to write or maintain many JavaServer Pages (JSPs). You can have JSPs that use “JavaBeans” or “JSP Custom Tags”; in both cases, you are simply using Java components that a developer has set up for you.因为Tomcat是用Java编写的,所以有些人认为你必须是Java大师才能使用它。事实并非如此!虽然你需要知道Java来修改Tomcat的内部结构或编写自己的servlet程序,但你不需要知道任何Java来使用Tomcat或编写或维护许多JavaServer Pages(JSP)。您可以使用“JavaBeans”或“JSP自定义标签”的JSP;在这两种情况下,您都只是使用开发人员为您设置的Java组件。

In this chapter, we explain how to install Tomcat, get it running, and test it to make sure that it’s functioning properly.在本章中,我们将解释如何安装Tomcat,使其运行,并对其进行测试以确保其正常运行。

Installing Tomcat安装Tomcat

There are several paths to getting Tomcat up and running. The quickest one is to download and run the compiled binary. Tomcat is written in Java, which means you need to have a modern and complete Java runtime installed before you can build or test it. Read Appendix A to make sure you have Java installed properly. Do not skip this step; it is more important than it sounds!有几种方法可以让Tomcat启动并运行。最快的方法是下载并运行编译后的二进制文件。Tomcat是用Java编写的,这意味着您需要安装一个现代完整的Java运行库,然后才能构建或测试它。阅读附录a以确保您正确安装了Java。不要跳过此步骤;这比听起来更重要!

One of the benefits of open source projects is that programmers find and fix bugs and make improvements to the software. If you’re not a programmer, there is little or nothing to be gained from recompiling Tomcat from its source code, as you are not interested in this level of interaction. Also, if you’re not an experienced Tomcat

developer, attempting to build and use your own Tomcat binaries may actually cause problems because it is relatively easy to build Tomcat in ways that quietly disable important features. To get started quickly, you should download an official release binary package for your system.开源项目的好处之一是程序员可以发现并修复错误,并对软件进行改进。如果你不是程序员,从源代码重新编译Tomcat几乎没有什么好处,因为你对这种级别的交互不感兴趣。此外,如果您不是经验丰富的Tomcat开发人员,尝试构建和使用自己的Tomcat二进制文件实际上可能会导致问题,因为以悄悄禁用重要功能的方式构建Tomcat相对容易。为了快速入门,您应该为您的系统下载一个官方发布的二进制包。

If you want some hints on compiling from source, see Chapter 9.如果你想了解一些从源代码编译的提示,请参阅第9章。

There are two levels of packaging. The Apache Software Foundation publishes bina- ries in the form of releases and nightly builds. Other organizations rebundle these into RPM packages and other kinds of installers for Linux, “packages” for BSD, and so forth. The best way to install Tomcat depends on your system. We explain the process on several systems: Linux, Solaris, Windows, Mac OS X, and FreeBSD.包装有两个层次。Apache软件基金会以发布和夜间构建的形式发布二进制文件。其他组织将这些重新打包成RPM包和其他类型的Linux安装程序、BSD“包”等。安装Tomcat的最佳方式取决于您的系统。我们解释了几个系统上的过程:Linux、Solaris、Windows、Mac OS X和FreeBSD。

Tomcat 6 requires any Java runtime version 1.5 or higher (which Sun’s marketing group calls “Java 5”). We suggest that you run Tomcat 6 on Java 1.6 or higher, how- ever, due to the additional features, fixes, and performance improvements that Java

1.6 (or higher) JVMs offer.Tomcat 6需要任何Java运行时版本1.5或更高版本(Sun的营销团队称之为“Java 5”)。然而,我们建议您在Java 1.6或更高版本上运行Tomcat 6,因为Java提供了额外的功能、修复和性能改进

1.6(或更高)JVM提供。

Installing Tomcat on Linux在Linux上安装Tomcat

Tomcat is available in at least two different binary release forms for Linux users to choose from:Tomcat至少有两种不同的二进制版本供Linux用户选择:

Multiplatform binary releases多平台二进制版本

You can download, install, and run any of the binary releases of Tomcat from Apache’s web site regardless of the Linux distribution you run. This format comes in the form of gzipped tar archives (tar.gz files) and zip archive files. This allows you to install Tomcat into any directory you choose, and you can install it as any user ID in the system. However, this kind of installation is not tracked by any package manager and will be more difficult to upgrade or uninstall later.

Also, it does not come with an init script for integration into the system’s star-

tup and shutdown.您可以从Apache的网站下载、安装和运行Tomcat的任何二进制版本,而不管您运行的是哪种Linux发行版。这种格式以gzip压缩的tar存档(tar.gz文件)和zip存档文件的形式出现。这允许您将Tomcat安装到您选择的任何目录中,并且可以将其作为系统中的任何用户ID安装。但是,这种安装不会被任何软件包管理器跟踪,以后升级或卸载会更加困难。此外,它没有附带用于集成到系统启动和关闭中的init脚本。

Distribution native package分发本地包

If you run Fedora or Red Hat Linux (or another Linux that uses the Red Hat package manager, such as SUSE or Mandriva), you can download a binary RPM package of Tomcat. This allows for easy uninstalls and upgrades via the Red Hat

Package Manager, plus it installs a Tomcat init script for stopping, starting, and

restarting Tomcat from the command line and on reboots. The downside to this

method of installation is that you must install the Tomcat RPM package as the root user. As of this writing there are at least two RPM package implementa- tions for you to choose from, each with different features.如果你运行Fedora或Red Hat Linux(或使用Red Hat软件包管理器的其他Linux,如SUSE或Mandriva),你可以下载Tomcat的二进制RPM软件包。这允许通过Red Hat软件包管理器轻松卸载和升级,此外,它还安装了一个Tomcat init脚本,用于从命令行和重新启动Tomcat。这种安装方法的缺点是,您必须以root用户身份安装TomcatRPM包。在撰写本文时,至少有两个RPM包实现可供选择,每个都有不同的功能。

Keep in mind, though, that Linux is just the operating system kernel, and the com- plete operating system is a “distribution.” Today, there are many different Linux dis- tributions. Some examples include Fedora, Red Hat, Ubuntu, Mandriva, Gentoo, and Debian. Although any two Linux distributions tend to be similar, there are also usually enough differences that make it difficult for developers to write one script that runs successfully on two. Also, each Linux distribution may primarily use a dif- ferent native package manager, so each version of a distribution can change any number of things in the operating system, including Java* and Tomcat. It is not uncommon for Linux distributions to bundle software written in Java that does not work only because the distribution’s own package of it is broken in a subtle way. Distributions also tend to include old versions of Tomcat that are either unstable or less than ideal to run your web site compared to the latest stable version available. For these reasons, it’s almost always best to install your own recent stable version of Tomcat.不过,请记住,Linux只是操作系统内核,完整的操作系统是一个“发行版”。今天,有许多不同的Linux发行版。一些例子包括Fedora、RedHat、Ubuntu、Mandriva、Gentoo和Debian。尽管任何两个Linux发行版往往相似,但通常也有足够的差异,使得开发人员很难编写一个在两个版本上成功运行的脚本。此外,每个Linux发行版可能主要使用不同的本机包管理器,因此每个版本的发行版都可以更改操作系统中的任意数量的内容,包括Java*和Tomcat。Linux发行版捆绑用Java编写的软件并不罕见,因为发行版自己的软件包以一种微妙的方式被破坏了。发行版还倾向于包括旧版本的Tomcat,与最新的稳定版本相比,这些版本要么不稳定,要么不太适合运行您的网站。出于这些原因,最好安装自己最新的稳定版本的Tomcat。

Because there are so many Linux distributions, and because they are significantly dif- ferent from each other, giving specific instructions on how best to install Tomcat on each version of each Linux distribution is beyond the scope of this book. Luckily, there is enough similarity between the popular Linux distributions for you to follow more generic Linux installation instructions for installing Tomcat from an Apache binary release archive.因为Linux发行版太多了,而且它们之间存在很大差异,所以给出如何在每个Linux发行版的每个版本上最好地安装Tomcat的具体说明超出了本书的范围。幸运的是,流行的Linux发行版之间有足够的相似性,您可以按照更通用的Linux安装说明从Apache二进制版本存档中安装Tomcat。

If you run a Fedora or Red Hat Linux distribution, more than one implementation of Tomcat RPM packages exists for you to choose from:如果您运行Fedora或Red Hat Linux发行版,则存在多个Tomcat RPM包的实现供您选择:

The Tomcat RPM package that comes with this book本书附带的TomcatRPM包

This is a fully relocateable RPM package that can be easily rebuilt via a custom ant build file. It does not build Tomcat itself but instead bundles the official mul- tiplatform Apache release class binaries of the Tomcat 6 version of your choice. This RPM package depends on no other RPM packages, so it can be installed as a single package, but needs to be configured to use an installed Java runtime (JDK or JRE). See Appendix E for the full source listing of the RPM package’s scripts.这是一个完全可重定位的RPM包,可以通过自定义ant构建文件轻松重建。它不构建Tomcat本身,而是捆绑了您选择的Tomcat 6版本的官方多平台Apache发布类二进制文件。此RPM包不依赖于其他RPM包,因此它可以作为单个包安装,但需要配置为使用已安装的Java运行时(JDK或JRE)。RPM包脚本的完整源代码列表见附录E。

The Tomcat RPM package that is available from JPackage.org可从JPackage.org获得的Tomcat RPM包

This is a nonrelocateable RPM package that installs Tomcat into the /var direc- tory. It rebuilds Tomcat from source code and then packages up the resulting multiplatform class binaries. This RPM package depends on many other RPM packages (each potentially requiring yet more packages) from JPackage.org and must be installed as a graph of RPM packages. As of this writing, JPackage.org does not have a Tomcat 6.0 RPM, only a Tomcat 5.5 RPM.这是一个不可定位的RPM包,它将Tomcat安装到/var/directory中。它从源代码重建Tomcat,然后打包生成的多平台类二进制文件。此RPM包依赖于JPackage.org上的许多其他RPM包(每个包都可能需要更多的包),必须以RPM包的图形形式安装。在撰写本文时,JPackage.org没有Tomcat 6.0 RPM,只有Tomcat 5.5 RPM。

  • See Appendix A for more information about how to work around a distribution’s incompatible Java implementation.有关如何解决发行版不兼容的Java实现的更多信息,请参阅附录A。

Each of these RPM packages includes detailed scripts for installing, uninstalling, and upgrading Tomcat, as well as scripts for runtime integration with the operating sys- tem. We suggest you try ours first.这些RPM包中的每一个都包括用于安装、卸载和升级Tomcat的详细脚本,以及用于与操作系统进行运行时集成的脚本。我们建议你先试试我们的。

If you run Gentoo Linux, there is an ebuild of Tomcat 6 that you can install and use. See the guide for it by William L. Thomson Jr. at http://www.gentoo.org/proj/en/java/ tomcat6-guide.xml. Also, see the Tomcat Gentoo ebuild page on the Gentoo Wiki at http://gentoo-wiki.com/Tomcat_Gentoo_ebuild. In addition to the ebuild, the RPM package from this book is written to install and run on Gentoo; just install the rpm command first.如果您运行Gentoo Linux,则可以安装和使用Tomcat 6的ebuild。请参阅William L.Thomson Jr.的指南,网址为http://www.gentoo.org/proj/en/java/tomcat6-guide.xml。此外,请参阅Gentoo Wiki上的Tomcat Gentoo ebuild页面,网址为http://gentoo-wiki.com/Tomcat_Gentoo_ebuild.除了ebuild之外,本书中的RPM包也是为在Gentoo上安装和运行而编写的;只需先安装rpm命令。

Installing Tomcat from an Apache multiplatform binary release从Apache多平台二进制版本安装Tomcat

For security reasons, you should probably create a tomcat user with low privileges and run Tomcat as that user. We suggest setting that user’s login shell to /sbin/出于安全原因,您可能应该创建一个权限较低的tomcat用户,并以该用户身份运行tomcat。我们建议将用户的登录shell设置为/sbin/

nologin and locking the user’s password so that it can’t be guessed. Also, it’s proba- bly a good idea to make the tomcat user’s primary group the nobody group or another group with similarly low permissions. You will need to do this as the root user:

nologin并锁定用户的密码,使其无法被猜测。此外,将tomcat用户的主组设置为nobody组或具有类似低权限的另一个组可能是个好主意。您需要以root用户身份执行此操作:

# useradd -g 46 -s /sbin/nologin -d /opt/tomcat/temp tomcat

If you do not have root access, you could run Tomcat as your login user, but beware that any security vulnerabilities (which are extremely rare) in Tomcat could be exploited remotely as your user account.如果您没有root访问权限,您可以作为登录用户运行Tomcat,但要注意,Tomcat中的任何安全漏洞(极为罕见)都可能作为您的用户帐户被远程利用。

Now download a release archive from the Apache binary release page at http:// tomcat.apache.org/download-60.cgi. You should download the latest stable version as listed on the Tomcat home page at http://tomcat.apache.org.现在,从Apache二进制发布页面http://tomcat.Apache.org/download-60.cgi下载发布存档。您应该下载Tomcat主页上列出的最新稳定版本,网址为http://tomcat.apache.org.

Even if you intend to install only a subset of the archive files of the Tomcat version you chose, you should download all of the archive files for that version in case you need them later. The Apache Soft- ware Foundation does archive releases of Tomcat, but you should store your own copies as well. If you are a heavy user of Tomcat, you should probably also download archives of the source code for your release and store your own copies of them as well so that you may investigate any potential bugs you may encounter in the version you’ve chosen.即使您打算只安装您选择的Tomcat版本的存档文件的一个子集,您也应该下载该版本的所有存档文件,以备以后需要。Apache软件基金会对Tomcat的版本进行存档,但您也应该存储自己的副本。如果您是Tomcat的重度用户,您可能还应该下载您版本的源代码档案,并存储自己的副本,以便您可以调查您在所选版本中可能遇到的任何潜在错误。

Uncompress the main Tomcat binary release archive. If you downloaded the apache- tomcat-6.0.14.tar.gz archive, for example, uncompress it wherever you want Tom- cat’s files to reside:解压缩主Tomcat二进制版本存档。例如,如果您下载了apache-tomcat-6.0.14.tar.gz存档,请将其解压缩到您希望tomcat文件所在的任何位置:

$ cd $HOME

$ tar zxvf apache-tomcat-6.0.14.tar.gz

Before you go any further, you should briefly look at the RELEASE-NOTES text file that resides in the root of your new Tomcat installation. It contains important informa- tion for everyone installing Tomcat and can give you details specific to the version you downloaded. Something else that is very important for you to do before proceeding with the installation is to read the online Tomcat changelog for your branch of Tom- cat. For example, Tomcat 6.0’s online changelog is at http://tomcat.apache.org/ tomcat-6.0-doc/changelog.html. Regardless of the version of Tomcat you install and use, you should look at the bugs listed in the changelog because bugs that exist in your version are fixedin newer versions of Tomcat andwill show up in the changelog listed under newer versions.在进一步操作之前,您应该简要查看位于新Tomcat安装根目录中的RELEASE-NOTES文本文件。它包含了安装Tomcat的每个人的重要信息,并可以为您提供特定于您下载的版本的详细信息。在继续安装之前,您需要做的另一件非常重要的事情是阅读您的Tomcat分支的在线Tomcat更改日志。例如,Tomcat 6.0的在线更改日志位于http://tomcat.apache.org/tomcat-6.0-doc/changelog.html。无论您安装和使用的是哪个版本的Tomcat,您都应该查看更改日志中列出的错误,因为您的版本中存在的错误在较新版本的Tomcat中已修复,并将显示在较新的版本下列出的更改日志中。

Although Java 1.5.x runtimes work fine with Tomcat 6, it is suggested that you use Java 1.6.x.虽然Java 1.5.x运行时在Tomcat 6上运行良好,但建议您使用Java 1.6.x。

If you’ll be running Tomcat as user tomcat (or any user other than the one you log in as), you must install the files so that this user may read and write those files. After you have unpacked the archives, you must set the file permissions on the Tomcat files so that the tomcat user has read/write permissions. To do that for a different user account, you’ll need root (superuser) access again. Here’s one way to do that from the shell:如果您将以用户Tomcat(或您登录时以外的任何用户)身份运行Tomcat,则必须安装这些文件,以便该用户可以读取和写入这些文件。解压缩存档后,必须设置Tomcat文件的文件权限,以便Tomcat用户具有读/写权限。要为其他用户帐户执行此操作,您需要再次获得root(超级用户)访问权限。以下是从shell中执行此操作的一种方法:

# chown -R tomcat apache-tomcat-6.0.14

Tomcat should now be ready to run, although it will not restart on reboots. To learn how to make it run when your server computer boots up, see “Automatic Startup,” later in this chapter.Tomcat现在应该可以运行了,尽管它不会在重新启动时重新启动。要了解如何在服务器计算机启动时使其运行,请参阅本章后面的“自动启动”。

Installing Tomcat from this book’s Linux RPM packages从本书的Linux RPM软件包安装Tomcat

This book contains a production quality example of a Tomcat RPM package for Linux (see Appendix E for the source). It serves as both an elegant way to get Tom- cat installed and running on Linux and as an example of how you may build your own custom Tomcat RPM package.本书包含一个用于Linux的Tomcat RPM包的生产质量示例(源代码见附录E)。它既可以作为在Linux上安装和运行Tomcat的优雅方式,也可以作为构建自己的自定义TomcatRPM包的示例。

Before you begin, you must install Apache Ant (http://ant.apache.org) version 1.6.2 or higher (but not version 1.6.4—that release was broken), preferably 1.7.x or higher. It must be usable from the shell, like this:在开始之前,您必须安装Apache Ant(http://ant.apache.org)1.6.2或更高版本(但不是1.6.4版本——该版本已损坏),最好是1.7.x或更高。它必须可以从shell中使用,如下所示:

# ant -version

Apache Ant version 1.7.0 compiled on December 13 2006

You must also have the rpmbuild binary available in your shell. In Fedora and Red Hat distributions, this is part of the RPM package named rpm-build. You must use version 4.2.1 or higher (the 4.2.0 version that is included with Red Hat 9 has a bug that prevents rpmbuild from working properly—but that is becoming antiquated!). Just make sure it’s installed and you can run the rpmbuild command successfully:您还必须在shell中提供rpmbuild二进制文件。在Fedora和Red Hat发行版中,这是名为RPM build的RPM包的一部分。您必须使用4.2.1或更高版本(Red Hat 9附带的4.2.0版本有一个错误,导致rpmbuild无法正常工作,但这已经过时了!)。只要确保它已安装,您就可以成功运行rpmbuild命令:

# rpmbuild --version

RPM version 4.3.2

Download this book’s examples archive from从以下网址下载本书的示例档案 http://catalog.oreilly.com/examples/ 9780596101060.

Unpack it like this:像这样解压缩

$ unzip tomcatbook-examples-2.0.zip

Change directory into the tomcat-package directory:将目录更改为tomcat包目录:

$ cd tomcatbook-examples/tomcat-package

Now, download the binary release archives from the Apache binary releases page at Apache Download Mirrors. You should download the latest stable ver- sion as listedon the Tomcat home page at http://tomcat.apache.org. Downloadall the tar.gz archive files for the version of Tomcat that you’ve chosen.现在,从Apache二进制发布页面下载二进制发布档案,网址为http://tomcat.apache.org/download-60.cgi.您应该下载Tomcat主页上列出的最新稳定版本,网址为http://tomcat.apache.org.下载您选择的Tomcat版本的所有tar.gz存档文件。

Move all the Tomcat binary release archive files into the tomcatbook-examples/ tomcat-package/ directory so they can be included in the RPM package set you’re about to build:将所有Tomcat二进制发布存档文件移动到tomcatbook examples/Tomcat package/目录中,以便它们可以包含在您要构建的RPM包集中:

# cp apache-tomcat-6.0.14*.tar.gz tomcatbook-examples/tomcat-package/

Edit the conf/tomcat-env.sh file to match the setup of the machines where you’ll deploy your Tomcat RPM packages. At the minimum, you should make sure that JAVA_HOME is an absolute filesystem path to a Java 1.5 or 1.6 compliant virtual machine (either a JDK or a JRE).编辑conf/tomcat-env.sh文件,使其与部署TomcatRPM包的机器的设置相匹配。至少,您应该确保JAVA_HOME是指向JAVA 1.5或1.6兼容虚拟机(JDK或JRE)的绝对文件系统路径。

Then, invoke ant to build your Tomcat 6 RPM package set:然后,调用ant来构建Tomcat 6 RPM包集:

$ ant

This should build the Tomcat RPM packages, and when the build is complete, you will find them in the dist/ directory:这应该构建Tomcat RPM包,构建完成后,您将在dist/目录中找到它们:

# ls dist/

tomcat-6.0.14-0.noarch.rpm tomcat-6.0.14-0-src.tar.gz tomcat-6.0.14-0.src.rpm tomcat-6.0.14-0.tar.gz

The Tomcat RPM package builder also builds a Tomcat source RPM package,* plus a

tar.gz archive of the RPM package as a convenience.TomcatRPM包构建器还构建了一个Tomcat源RPM包,*以及一个

tar.gz归档RPM包,以方便使用。

Copy the RPM package to the machine(s) you wish to install it on. When you’re ready to install it, you have two choices:将RPM软件包复制到要安装它的机器上。当你准备安装它时,你有两个选择:

  • Install it into its default path of /opt/tomcat.将其安装到默认路径/opt/tomcat中。
  • Install it, relocating it to a path of your choice. Here’s how to install it to the default path:安装它,将其重新定位到您选择的路径。以下是如何将其安装到默认路径:

  • Think of this source RPM package as the content necessary to buildthe binary RPM package, not necessarily the Java source code to Tomcat itself. This book’s Tomcat RPM package was built using the officially com- piled Tomcat class files, so the Java source isn’t included in the source RPM package, nor is it necessary to build the multiplatform “binary” RPM package.将此源RPM包视为构建二进制RPM包所必需的内容,而不一定是Tomcat本身的Java源代码。本书的TomcatRPM包是使用官方编译的Tomcat类文件构建的,因此Java源代码不包含在源RPM包中,也不需要构建多平台的“二进制”RPM包。

# rpm -ivh tomcat-6.0.14-0.noarch.rpm

Preparing... ########################################### [100%]

1:tomcat ########################################### [100%]

The following error:

error: Failed dependencies:

/bin/sh is needed by tomcat-6.0.14-0.noarch

usually occurs on operating systems that do not primarily use the RPM package manager, and you are installing this Tomcat RPM package when the RPM package manager’s database is empty (no package in the database provides the /bin/sh inter- preter). This may happen, for example, if you are installing the Tomcat RPM pack- age on a Debian Linux OS after installing the rpm command.通常发生在主要不使用RPM包管理器的操作系统上,当RPM包管理程序的数据库为空时(数据库中没有包提供/bin/sh解释器),您正在安装此Tomcat RPM包。例如,如果您在安装RPM命令后在Debian Linux操作系统上安装Tomcat RPM包,则可能会出现这种情况。

Try to install it again like this:请尝试按如下方式重新安装:

# rpm -ivh --nodeps tomcat-6.0.14-0.noarch.rpm

If you get warnings such as these about users and groups:如果您收到关于用户和组的此类警告:

warning: user tomcat does not exist - using root warning: group nobody does not exist - using root

you need to add a tomcat user and nobody group by hand using adduser and addgroup. Just make sure that the tomcat user’s primary group is nobody. Also, make sure that you set user tomcat’s home directory to “/opt/tomcat/temp,” and set tomcat’s login shell to something that doesn’t actually work, such as /sbin/nologin if you have that:您需要使用adduser和addgroup手动添加tomcat用户和nobody组。只要确保tomcat用户的主要组是nobody。此外,请确保将用户tomcat的主目录设置为“/opt/tomcat/temp”,并将tomcat的登录shell设置为实际上不起作用的东西,例如/sbin/nologin(如果有的话):

# groupadd nobody

# useradd -s /sbin/nologin -d /opt/tomcat/temp -c 'Tomcat User' \

-g nobody tomcat

Once you are done with this, try again to install the tomcat package:完成此操作后,请再次尝试安装tomcat软件包:

# rpm -e tomcat

# rpm -ivh --nodeps tomcat-6.0.14-0.noarch.rpm

Once it’s installed, just verify that the JAVA_HOME path set in /opt/tomcat/conf/ tomcat-env.sh points to the 1.5 or 1.6 JVM that you want it to. That’s it! Tomcat should be ready to run.安装后,只需验证/opt/tomcat/conf/tomcat-env.sh中设置的JAVA_HOME路径是否指向您想要的1.5或1.6 JVM。就是这样!Tomcat应该可以运行了。

With these same RPM packages, you can install Tomcat and relocate it to a different filesystem path, like this:使用这些相同的RPM包,您可以安装Tomcat并将其重新定位到不同的文件系统路径,如下所示:

rpm -ivh --prefix /usr/local tomcat-6.0.14-0.noarch.rpm

This would install Tomcat, relocating it so that CATALINA_HOME becomes /usr/ local/tomcat. You may install the admin and compat packages this way as well.这将安装Tomcat,重新定位它,使CATALINA_HOME变为/usr/local/Tomcat。您也可以通过这种方式安装admin和compat软件包。

As of this writing, JPackage.org does not offer a Tomcat 6 RPM pack- age, but instead offers a Tomcat 5.5 RPM package.在撰写本文时,JPackage.org没有提供Tomcat6RPM包,而是提供了Tomcat5.5RPM包。

Installing Tomcat from the JPackage.org Linux RPM packages从JPackage.org Linux RPM软件包安装Tomcat

To download and install the JPackage.org Tomcat RPM packages, visit http://JPackage. org/repos.php. This page discusses how to configure meta package managers, such as yumapt-rpmurpmi, and up2date. This is the only reasonable way to install the JPack- age.org Tomcat RPM package set due to its large number of installation dependencies. Also, because the details about how to set up the repository configuration for the meta package manager can change at any time, we are not able to show an example of how to do it in this book. See JPackage.org’s web site for the details.要下载并安装JPackage.org Tomcat RPM软件包,请访问http://JPackage.org/repos.php。本页讨论如何配置元包管理器,如yum、apt-rpm、urpmi和up2date。由于JPack-age.org Tomcat RPM包集有大量的安装依赖关系,这是安装该包集的唯一合理方法。此外,由于有关如何为元包管理器设置存储库配置的详细信息可能随时更改,因此我们无法在本书中展示如何操作的示例。有关详细信息,请参阅JPackage.org的网站。

The JPackage.org Tomcat 5.5 RPM creates a user and group both named tomcat5 and runs Tomcat with that user and group. The default shell of the tomcat5 user is /bin/sh. Don’t try to change this or Tomcat will stop running correctly.JPackage.org Tomcat 5.5 RPM创建了一个名为tomcat5的用户和组,并使用该用户和组运行Tomcat。tomcat5用户的默认shell是/bin/sh。不要尝试更改此shell,否则Tomcat将停止正常运行。

Installing Tomcat on Solaris在Solaris上安装Tomcat

Before you install a new Tomcat package on Solaris, you shouldprobably inspect your system to find out if there is already one present and decide if you should remove it. By default, no Tomcat package should be installed, at least on Sun’s Solaris 10.在Solaris上安装新的Tomcat包之前,您可能应该检查您的系统,看看是否已经存在一个,并决定是否应该删除它。默认情况下,不应安装任何Tomcat包,至少在Sun的Solaris 10上是这样。

Solaris 9 ships with an older version of Tomcat. Check to see if it’s installed:Solaris 9附带了旧版本的Tomcat。检查是否已安装:

jasonb$ pkginfo | grep -i tomcat

If this command outputs one or more packages, a version of Tomcat is installed. To get more information about the package, use pkginfo

with the -l switch. For example, if the preinstalled Tomcat package name was SUNWtomcat:如果此命令输出一个或多个包,则安装了一个版本的Tomcat。要获取有关该软件包的更多信息,请将pkginfo与-l开关一起使用。例如,如果预安装的Tomcat包名为SUNWtomcat:

jasonb$ pkginfo -l SUNWtomcat

Even if Tomcat is installed, it should not cause problems. To be safe, we suggest that you uninstall an existing Tomcat package only if you’re prepared to deal with any breakage that removal may cause. If you’re sure the package is causing you problems, as the root user, you can remove it:即使安装了Tomcat,也不会造成问题。为了安全起见,我们建议您只有在准备好处理删除可能导致的任何损坏时,才卸载现有的Tomcat软件包。如果你确定这个包给你带来了问题,作为root用户,你可以删除它:

# pkgrm SUNWtomcat

To install a Tomcat Solaris package, you need to set your user identity to the root user or else you will not have sufficient permissions to write the files. Usually, this is done either with the sudo or su commands. For example:要安装Tomcat Solaris软件包,您需要将用户标识设置为root用户,否则您将没有足够的权限写入文件。通常,这是通过sudo或su命令完成的。例如:

# su -

Password:

Sun Microsystems Inc. SunOS 5.10 Generic January 2005 # id

uid=0(root) gid=0(root)

Then, you can proceed with the installation.然后,您可以继续安装。

Solaris already comes standard with Java 1.5.0, but you should make sure to upgrade it to a newer, more robust version. See Appendix A for details on what to get and where to get it.Solaris已经是Java 1.5.0的标准配置,但您应该确保将其升级到更新、更健壮的版本。有关获取内容和获取位置的详细信息,请参阅附录A。

As of this writing, the only Solaris package of Tomcat that we could find is a Tomcat

5.5 package included in the Blastwave Solaris Community Software (CSW) package set. This package set is a community supported set of open source packages, analo- gous to a Linux distribution’s package set. See the Blastwave CSW page about it at

http://www.blastwave.org. The CSW package is best installed via the pkg-get com-

mand. This command does not come with Solaris, but it is easy to install.在撰写本文时,我们唯一能找到的Tomcat Solaris包是Tomcat Blastwave Solaris社区软件(CSW)包集中包含的5.5包。这个包集是一组社区支持的开源包,类似于Linux发行版的包集。请参阅Blastwave CSW页面 http://www.blastwave.org.CSW软件包最好通过pkg-get com安装- 曼德。Solaris不附带此命令,但安装起来很容易。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值