Installing Tomcat
来源:互联网 发布:ubuntu设置开机自启 编辑:程序博客网 时间:2024/05/21 08:59
Chapter 3. InstallingTomcat
This chapter coversdownloading and installing the Tomcat binaries on a Linux system.
3.1.Prerequisites
Before we begin, wewill need to have a Java 2 SDK installed. This document is based on the IBMJava 2 SDK v 1.4.1. With Tomcat 5, because of dramatic changes in Linux in thelast year, there are a few things you will need to be aware of.
If you are using RedHat 9, Fedora Core or any Linux distribution that uses the NPTL (Native POSIXThread Library), you may have problems getting Java to run properly. If you'regetting frequent segmentation faults, you might want to turn off NPTL. Myadvice is to get the latest versions of everything, that is, install version1.4.1 of the Java 2 SDK or better, and get the 2.6 Linux kernel for superior performance.
I will not cover theinstallation of the Java SDK here. I have a write-up on this -- and how you canturn off NPTL -- at this location.
There are significantdifferences between Tomcat 4 and Tomcat 5.
3.2.Downloading The Software
You can find theTomcat binaries at : http://jakarta.apache.org/site/binindex.cgi.Scroll to the bottom of the page to find the links for Tomcat 5.x, 4.x and theweb server connectors.
With Tomcat 5, thereare now 7 files available for download. If you are running Linux/UNIX, thepackage you are looking for is the tarball, which at the time of this writingis 5.0.18 tar.gz. Click on the link and your download should startautomatically.
Table 3-1. Tomcat 5 Packages as at 14 February 2004
Package Name
Operating System
Remarks
jakarta-tomcat-5.0.25.tar.gz
UNIX/Linux
This is the base Tomcat package. The servlet engine and startup scripts are in this package.
jakarta-tomcat-5.0.25-deployer.tar.gz
UNIX/Linux
This is the Tomcat Deployer package. The deployer is for easily deploying and undeploying web applications, especially if you are using an IDE. See the Appendix for integrating the deployer with Eclipse.
jakarta-tomcat-5.0.25-embed.tar.gz
UNIX/Linux
This is the embedded Tomcat package. [TBD]
jakarta-tomcat-5.0.25.exe
Microsoft Windows
This is the installer for Microsoft Windows. This probably works on NT4/2000/XP. Not so sure about 95/98/ME. If you know, please email me.
jakarta-tomcat-5.0.25.zip, jakarta-tomcat-5.0.25-deployer.zip, jakarta-tomcat-5.0.25-embed.zip
Windows/UNIX/Linux
You can use this zip file on UNIX/Linux, but you will have to remember to set the permissions properly before it will work. Why go to all that trouble? Just use the tar package.
If you are usingWindows, you have a choice of either the zip file or the EXE file. I haven'ttried running Tomcat 5 on Windows, so I cannot say anything else about it.
3.3.Installing The Software
There are many waysthat you can get Tomcat installed on your Linux system. You could use the rpm'sthat are now available on jpackage.org or the tarballs from theJakarta site. This document covers only the Jakarta tarballs. I have never usedthe rpm packages before.
If you have alreadydownloaded the binary, simply copy it to the directory you want to install itunder and expand the file. For example, if I downloaded the Tomcat tar fileinto /home/someuser/downloads and wanted toinstall it under /opt, here is what I woulddo. As root user:
# cp /home/someuser/downloads/jakarta-tomcat-5.x.xx.tar.gz /opt
# tar -zxvf jakarta-tomcat-5.x.xx.tar.gz
A directory calledjakarta-tomcat-5.x.xx will be created and the Tomcat files will expand underit.
Previously, I wouldhave recommended that the jakarta-tomcat-5.x.xx directory berenamed to just tomcat. However, because Iexpect Tomcat 5 to be updated more frequently for now, since it has only justbeen released, I would instead recommend creating a symbolic link to a tomcat directory.
# ln -s jakarta-tomcat-5.0.25 tomcat
In order for Tomcatto startup and shutdown, you will also need to add an environment variablepointing to the Tomcat directory (CATALINA_HOME), and one variable pointing toyour Java SDK directory (JAVA_HOME). I will make the following assumptions:
JAVA_HOME
Java is installedinto /opt/IBMJava2-141.
CATALINA_HOME
Tomcat is installedinto /opt/jakarta-tomcat-5.x.xx and symlinkedto /opt/tomcat.
Insert the followinglines inside /etc/profile or /root/.bashrc.
export JAVA_HOME=/opt/IBMJava2-141
export CATALINA_HOME=/opt/tomcat
Now, save the fileand reboot the system to ensure that all changes take effect.
3.4.Starting and Stopping Tomcat
Before we begin, wewill need to ensure that CATALINA_HOME and JAVA_HOME are correctly set. To dothis, we open a terminal and type the following :
# echo $CATALINA_HOME
# echo $JAVA_HOME
If you get a blankline, or if the directory points anywhere besides where it is supposed to, youwill have to correct these environment variables first, before continuing.
If everything isfine, you can start Tomcat with the following command. As root,
# $CATALINA_HOME/bin/startup.sh
To check if Tomcat isrunning fine, you should open a browser and point the URL tohttp://localhost:8080. You should see the default Tomcat welcome page. It wouldbe a good idea, at this point, to browse the documentation or try out theexample servlets and JavaServer Pages samples.
To stop Tomcat, asroot,
# $CATALINA_HOME/bin/shutdown.sh
If Tomcat does notstart and you downloaded the zip file, the cause is probably due topermissions. Ensure that the following files are executable : inside $CATALINA_HOME/bin directory,
# chmod +x startup.sh
# chmod +x shutdown.sh
# chmod +x tomcat.sh
After you have madethe files executable, try starting and stopping Tomcat again.
3.5.Running Tomcat as Non-Root User
I don't believe thereany issues with running Tomcat as root user. However, for the moresecurity-conscious readers out there, here are some instructions on running Tomcatas a non-root user.
At this stage, theTomcat packages, files and binaries are owned by root. We will first need tocreate a Tomcat user and group that will own these files, and under whichTomcat will run.
Tomcat User :: tomcat
Tomcat Group :: tomcat
Not too imaginative,huh ? We will now create the Tomcat user and group. Open a terminal window and,as root,
# groupadd tomcat
# useradd -g tomcat -d /opt/tomcat tomcat
# passwd tomcat
Notice that wespecified the home directory of Tomcat to be /opt/tomcat. Some people believethat this is good practice because it eliminates an additional home directorythat needs to be administered.
Now, we will puteverything in /opt/tomcat under Tomcat user and group. As root,
# chown -R tomcat:tomcat /opt/tomcat
If /opt/tomcat is a symlink to your Tomcat installdirectory, you'll need to do this:
# chown -R tomcat:tomcat /opt/jakarta-tomcat-5.x.xx
Verify that JAVA_HOMEand CATALINA_HOME environment variables are setup for tomcat user, and youshould be good to go. Once the Tomcat binaries are under Tomcat user, the wayyou invoke it will be different.
To start Tomcat,
# su - tomcat -c /opt/tomcat/bin/startup.sh
To stop Tomcat,
# su - tomcat -c /opt/tomcat/bin/shutdown.sh
Also, be aware thatyour web applications will need to be deployed (i.e. copied to the webapplication directories) as user tomcat, instead of root. A little more hassle,but possibly a little safer too.
- Installing Tomcat
- Installing Tomcat 6 on Ubuntu
- 实践补充 Installing Tomcat 7.0.x on OS X
- Installing Tomcat 8 on OS X 10.10 Yosemite
- Installing OpenGrok and Tomcat 7 on Ubuntu 13.04 quickly
- Tomcat 指定的服务已存在 Failed installing 'Tomcat8'
- I am going to Macau tomorrow, and now I am installing Tomcat 4
- Installing JBoss jBPM 3.2.2 on Apache Tomcat 5.5 and MySQL
- Installing Apache Tomcat 5.5/6/7 with a multi-instance layout on Linux
- 运行tomcat 出错:Skipped installing application listeners due to previous error(s)
- How Tomcat workd 之第十章 Installing the Authentictor Value 安装校验值
- Installing unixODBC
- Installing BIRT
- Installing GCC
- Installing Rails
- Installing GeoWebCache
- gcc installing
- VE/Installing
- jQuery UI 应用不同Theme的办法
- 无线网络破解,破解wap密码
- To install the Linux (self-extracting) file
- 基于OpenGL动画设计研究与实现
- OutLook 编程
- Installing Tomcat
- 21、Linux图形界面中客户端、服务器、窗口管理器之间的关系
- Install JDK 7 on Ubuntu desktop.
- 主流双核处理器对比
- Windows下JSP开发环境的配置
- Windows CE 6.0 安装顺序
- Email Header Analyzer 电子邮件信件头部内容分析器
- 好博客
- 22、Oracle 数据库的启动和关闭的方式!