linux tomcat
1.下载Tomcat
http://tomcat.apache.org/download-60.cgi
选定Tomcat6对应的系统版本,这里针对linux/unix系统,选择下载得到的文件是:apache-tomcat-6.0.32.tar.gz
2.创建Tomcat安装目录。
在Linux系统硬盘系统文件夹usr下创建一个文件夹tomcat。
命令:sudomkdirtomcat
3.复制Tomcat安装包到系统指定文件夹。
把下载的安装文件(apache-tomcat-6.0.32.tar.gz)拷到linux路径/usr/tomcat下。
4安装Tomcat。
在当前/usr/tomcat下
开始安装,执行命令:tar-zxvfapache-tomcat-6.0.32.tar.gz
(如果因权限问题执行失败,则加上sudo,即sudotar-zxvfapache-tomcat-6.0.32.tar.gz)
文件会被安装到当前目录/usr/tomcat/apache-tomcat-6.0.32
5.给apache-tomcat-6.0.32文件夹加读写权限
sudochmod-Ro+rwapache-tomcat-6.0.32
6.指定JDK路径指定到Tomcat,非常关键的一步
在/usr/tomcat/apache-tomcat-6.0.32/setclasspath.sh文件中,加上红色的两行,目的是引用JDK的环境变量,之前的JDK设置环境变量(JAVA_HOME,JRE_HOME)很奇怪不能调用,,找了很多资料,重新export就OK了。
visetclasspath.sh
#!/bin/sh
#LicensedtotheApacheSoftwareFoundation(ASF)underoneormore
#contributorlicenseagreements.SeetheNOTICEfiledistributedwith
#thisworkforadditionalinformationregardingcopyrightownership.
#TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0
#(the"License");youmaynotusethisfileexceptincompliancewith
#theLicense.YoumayobtainacopyoftheLicenseat
#
#http://www.apache.org/licenses/LICENSE-2.0
#
#Unlessrequiredbyapplicablelaworagreedtoinwriting,software
#distributedundertheLicenseisdistributedonan"ASIS"BASIS,
#WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.
#SeetheLicenseforthespecificlanguagegoverningpermissionsand
#limitationsundertheLicense.
#-----------------------------------------------------------------------------
#SetCLASSPATHandJavaoptions
#
#$Id:setclasspath.sh7950372009-07-1710:52:16Zmarkt$
#-----------------------------------------------------------------------------
exportJAVA_HOME=/usr/java/jdk1.6.0_24
exportJRE_HOME=/usr/java/jdk1.6.0_24/jre
#Makesureprerequisiteenvironmentvariablesareset
if[-z"$JAVA_HOME"-a-z"$JRE_HOME"];then
#Bugzilla37284(reviewed).
if$darwin;then
if[-d"/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home"];then
exportJAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home"
fi
else
JAVA_PATH=`whichjava2>/dev/null`
if["x$JAVA_PATH"!="x"];then
JAVA_PATH=`dirname$JAVA_PATH2>/dev/null`
JRE_HOME=`dirname$JAVA_PATH2>/dev/null`
fi
if["x$JRE_HOME"="x"];then
#XXX:Shouldwetryotherlocations?
if[-x/usr/bin/java];then
JRE_HOME=/usr
fi
fi
fi
if[-z"$JAVA_HOME"-a-z"$JRE_HOME"];then
echo"NeithertheJAVA_HOMEnortheJRE_HOMEenvironmentvariableisdefined"
echo"Atleastoneoftheseenvironmentvariableisneededtorunthisprogram"
exit1
fi
fi
if[-z"$JAVA_HOME"-a"$1"="debug"];then
echo"JAVA_HOMEshouldpointtoaJDKinordertorunindebugmode."
exit1
fi
if[-z"$JRE_HOME"];then
JRE_HOME="$JAVA_HOME"
fi
#Ifwe'rerunningunderjdb,weneedafulljdk.
if["$1"="debug"];then
if["$os400"="true"];then
if[!-x"$JAVA_HOME"/bin/java-o!-x"$JAVA_HOME"/bin/javac];then
echo"TheJAVA_HOMEenvironmentvariableisnotdefinedcorrectly"
echo"Thisenvironmentvariableisneededtorunthisprogram"
echo"NB:JAVA_HOMEshouldpointtoaJDKnotaJRE"
exit1
fi
else
if[!-x"$JAVA_HOME"/bin/java-o!-x"$JAVA_HOME"/bin/jdb-o!-x"$JAVA_HOME"/bin/javac];then
echo"TheJAVA_HOMEenvironmentvariableisnotdefinedcorrectly"
echo"Thisenvironmentvariableisneededtorunthisprogram"
echo"NB:JAVA_HOMEshouldpointtoaJDKnotaJRE"
exit1
fi
fi
fi
if[-z"$BASEDIR"];then
echo"TheBASEDIRenvironmentvariableisnotdefined"
echo"Thisenvironmentvariableisneededtorunthisprogram"
exit1
fi
if[!-x"$BASEDIR"/bin/setclasspath.sh];then
if$os400;then
#-xwillOnlyworkontheos400ifthefilesare:
#1.ownedbytheuser
#2.ownedbythePRIMARYgroupoftheuser
#thiswillnotworkiftheuserbelongsinsecondarygroups
eval
else
echo"TheBASEDIRenvironmentvariableisnotdefinedcorrectly"
echo"Thisenvironmentvariableisneededtorunthisprogram"
exit1
fi
fi
#Don'toverridetheendorseddiriftheuserhassetitpreviously
if[-z"$JAVA_ENDORSED_DIRS"];then
#Setthedefault-Djava.endorsed.dirsargument
JAVA_ENDORSED_DIRS="$BASEDIR"/endorsed
fi
#OSXhacktoCLASSPATH
JIKESPATH=
if[`uname-s`="Darwin"];then
OSXHACK="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes"
if[-d"$OSXHACK"];then
foriin"$OSXHACK"/*.jar;do
JIKESPATH="$JIKESPATH":"$i"
done
fi
fi
#SetstandardcommandsforinvokingJava.
_RUNJAVA="$JRE_HOME"/bin/java
if["$os400"!="true"];then
_RUNJDB="$JAVA_HOME"/bin/jdb
Fi
7.启动测试
在/usr/tomcat/apache-tomcat-6.0.32/bin路径下
a)在控制台输入:./startup.sh
以下是输出信息:
UsingCATALINA_BASE:/usr/tomcat/apache-tomcat-6.0.32
UsingCATALINA_HOME:/usr/tomcat/apache-tomcat-6.0.32
UsingCATALINA_TMPDIR:/usr/tomcat/apache-tomcat-6.0.32/temp
UsingJRE_HOME:/usr/java/jdk1.6.0_24/jre
UsingCLASSPATH:/usr/tomcat/apache-tomcat-6.0.32/bin/bootstrap.jar
b)用http://192.168.1.102:8080访问(192.168.1.102是我的系统IP)
如果访问成功,则Tomcat基本的配置已成功。
c)简单测试了一个编译好的应用程序放到webapps文件夹下,测试成功
d)关闭tomcat,执行命令:./shutdown.sh
以下是输出信息:
UsingCATALINA_BASE:/usr/tomcat/apache-tomcat-6.0.32
UsingCATALINA_HOME:/usr/tomcat/apache-tomcat-6.0.32
UsingCATALINA_TMPDIR:/usr/tomcat/apache-tomcat-6.0.32/temp
UsingJRE_HOME:/usr/java/jdk1.6.0_24/jre
UsingCLASSPATH:/usr/tomcat/apache-tomcat-6.0.32/bin/bootstrap.jar