1. Preparations before installation:
1. Linux version: [root @ tpwb/] # uname-r
2.6.9-34.EL( kernel version)
2, tomcat version: jakarta-tomcat-5.0.28.tar (size: 10.2 M)
You can go to http://jakarta.apache.org/tomcat to download
2. tomcat installation
Check the information about Tomcat installation before installation. The information about Tomcat installation is also available for reference.
3. Start installation.
[Root @ tpwb ~] # Cd/usr/local
[Root @ tpwb local] # ls
Bin games lib lost + found sbin src
Etc include jakarta-tomcat-5.0.28.tar.gz libexec man share
I put the j2sdk-1_4_2_04-linux-i586-rpm.bin in the local directory, you can also put it elsewhere.
Step 1:
Decompress the package first.
[Root @ tpwb local] # tar-zxvf jakarta-tomcat-5.0.28.tar.gz
[Root @ tpwb local] # ls
Bin games jakarta-tomcat-5.0.28 lib lost + found sbin src
Etc include jakarta-tomcat-5.0.28.tar.gz libexec man share
Step 2:
Set Environment Variables
Someone may ask why to set the environment variable.
Provide a URL at http://www.linuxidc.com/linux/2009-12/23735.htm?for details:
In general, you can find the tomcat directory by running the tomact command and know where it is installed.
Set two environment variables CATALINA_HOME and CATALINA_BASE,
Edit ~ /. Bashrc file. Join
Export CATALINA_BASE =/usr/local/jakarta-tomcat-5.0.28
Export CATALINA_HOME =/usr/local/jakarta-tomcat-5.0.28
[Root @ tpwb local] # cd ~
[Root @ tpwb ~] # Ls-
.. Bash_history. bashrc. gconfd install. log. syslog
... Bash_logout. cshrc. gtkrc. tcshrc
Anaconda-ks.cfg. bash_profile. gconf install. log. viminfo
[Root @ tpwb ~] # Vi. bashrc
If [-f/etc/bashrc]; then
./Etc/bashrc
Fi
Export JAVA_HOME =/usr/java/j2sdk1.4.2 _ 04
Export CLASSPATH = $ CLASSPATH: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib
Export PATH = $ JAVA_HOME/bin: $ JAVA_HOME/jre/bin: $ PATH: $ HOMR/bin
Export CATALINA_BASE =/usr/local/jakarta-tomcat-5.0.28
Export CATALINA_HOME =/usr/local/jakarta-tomcat-5.0.28
The vi command is used to edit text. Wq save and exit. For more detailed commands, you can view the above recommended web site
If you want to set environment variables for other users, the method is the same. I will not talk about it here. I have already explained in detail in the article "Install JDK under linux.
Next, verify whether the variable settings take effect.
You are advised to restart the environment variables after setting them. Otherwise, the effect will not be visible.
[Root @ tpwb tp] # reboot
Broadcast message from root (pts/0) (Fri Jan 19 16:51:26 2007 ):
The system is going down for reboot NOW!
Let's take a look.
[Root @ tpwb ~] # Echo $ CATALINA_HOME
/Usr/local/jakarta-tomcat-5.0.28
[Root @ tpwb ~] # Echo $ CATALINA_BASE
/Usr/local/jakarta-tomcat-5.0.28
No problem. Step 3:
Let's take a look at the port opened in linux:
[Root @ tpwb ~] # Netstat-l
Then, run the tomcat console
[Root @ tpwb ~] # Cd/usr/local/jakarta-tomcat-5.0.28
[Root @ tpwb jakarta-tomcat-5.0.28] # ls
Bin conf logs RELEASE-NOTES server temp work
Common license notice RUNNING.txt shared webapps
[Root @ tpwb jakarta-tomcat-5.0.28] # cd bin
[Root @ tpwb bin] # ls
Bootstrap. jar setclasspath. sh
Catalina.50.bat shutdown. bat
Catalina.50.sh shutdown. sh
Catalina. bat shutdown-using-launcher.bat
Catalina. sh shutdown-using-launcher.sh
Catalina. xml startup. bat
Commons-daemon.jar startup. sh
....
Pay attention to this file
Startup. sh
[Root @ tpwb bin]./startup. sh
Using CATALINA_BASE:/usr/local/jakarta-tomcat-5.0.28
Using CATALINA_HOME:/usr/local/jakarta-tomcat-5.0.28
Using CATALINA_TMPDIR:/usr/local/jakarta-tomcat-5.0.28/temp
Using JAVA_HOME:/usr/java/j2sdk1.4.2 _ 04
Let's take a look at the port currently opened in linux:
[Root @ tpwb ~] # Netstat-l
Is there an extra port 8080! This is the default Tomcat port/
Okay. Now we have started our installation and testing.
Http: // your IP address: 8080 indicates whether the tomcat Web page is displayed.
If you haven't seen it, close it.
[Root @ tpwb ~] # Service iptables stop
Clear firewall rules: [OK]
Set chains to ACCEPT policy: filter [OK]
Uninstalling the Iiptables module: [OK]
What if I want Tomcat to automatically load upon startup? Okay. Let's take a look!
The bin directory under the Tomcat installation directory has two scripts respectively used to start and stop Tomcat: startup. sh, shutdown. sh. You can use these two scripts to manually start and stop the Tomcat service and perform tests after installation.
The simplest method is to use startup. sh to automatically start Tomcat and edit/etc/rc. d/rc. add content in local (assume that the JDK directory is/usr/jdk, And the Tomcat directory is/apache/tomcat)
Export JDK_HOME =/usr/jdk
Export JAVA_HOME =/usr/jdk
/Apache/tomcat/bin/startup. sh
[Root @ tpwb ~] # Vi/etc/rc. d/rc. local
#! /Bin/sh
#
# This script will be executed * after * all the other init scripts.
# You can put your own initialization stuff in here if you dont
# Want to do the full Sys V style init stuff.
Touch/var/lock/subsys/local
Export JDK_HOME =/usr/java/j2sdk1.4.2 _ 04
Export JAVA_HOME =/usr/java/j2sdk1.4.2 _ 04
/Usr/local/jakarta-tomcat-5.0.28/bin/startup. sh
This is my directory.
In this way, Tomcat can be automatically started after the system is restarted.