cd /usr/local/src
wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.59/bin/apache-tomcat-7.0.59.zip
yum install unzip -y
unzip -d /usr/local apache-tomcat-7.0.59.zip
cd /usr/local
mv apache-tomcat-7.0.59/ tomcat7
vi /etc/profile
JAVA_HOME
在这个文件末尾加上export JAVA_HOME=/usr/java/jdk1.8.0
export JRE_HOME=/usr/java/jdk1.8.0/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:$JAVA_HOME/bin
TOMCAT_HOME
cd /usr/local/tomcat7/bin
vi catalina.sh
在#!/bin/sh
后面加上
export TOMCAT_HOME=/usr/local/tomcat7
export CATALINA_HOME=/usr/local/tomcat7
source /etc/profile
cd /usr/local/tomcat7/bin
chmod 777 *.*
echo "source /etc/profile" >>/etc/rc.d/rc.local
echo "/usr/local/tomcat7/bin/startup.sh" >>/etc/rc.d/rc.local
这里有点要说明,rc.local先于/etc/profile执行,所以会得不到JAVA环境变量,所以在startup.sh前加入代码:source /etc/profile 这样就可以
chkconfig iptables off iptables
service iptables stop
cd /usr/local/tomcat7/bin
./startup.sh