(1)下载apache-tomcat-7.0.30.tar.gz
(2)解压:tar -zxvf apache-tomcat-7.0.30.tar.gz
(3)复制到/usr/local下并重命名为tomcat7:sudo cp -R apache-tomcat-7.0.30 /usr/local/tomcat
(4)进入tomcat7下的bin目录: cd /usr/local/tomcat7/bin
(5)启动Tomcat7:sudo ./startup.sh
显示:Using CATALINA_BASE: /usr/local/tomcat7
Using CATALINA_HOME: /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME: /usr/Java/jdk1.7.0_07
Using CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
(6)关闭Tomcat7:sudo ./shutdown.sh
显示:Using CATALINA_BASE: /usr/local/tomcat7
Using CATALINA_HOME: /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME: /usr/java/jdk1.7.0_07
Using CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
(7)添加Tomcat环境变量:sudo vi /etc/profile,红色部分
#set environment variable
export JAVA_HOME=/usr/java/jdk1.7.0_07
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export TOMCAT_HOME=/usr/local/tomcat7
export CATALINA_HOME=/usr/local/tomcat7
export PATH=$PATH:$JAVA_HOME/bin
(8)使配置生效:sudosource /etc/profile。
(9)默认情况下,Tomcat并没提供具有管理权限的账号,所以需要添加具有这种权限的账号。角色manager-gui具有这种权限,但在系统用户控制文件tomcat-users.xml中并没有设置这两种角色和对应的用户,所以需要添加这种角色和用户,方法是打开tomcat-users.xml文件,添加如下内容:
<role rolename="manager-gui"/>
<user username="manager" password="manager" roles="manager-gui"/>
windows:
set java_home:查看JDK安装路径
java -version:查看JDK版本
linux:
whereis java
which java (java执行路径)
echo $JAVA_HOME
echo $PATH
找到jdk安装目录的_uninst子目录 ·在shell终端执行命令./uninstall.sh即可卸载jdk。