系统环境变量
/etc/profile
配置jdk
export JAVA_HOME=/usr/local/soft/jdk1.8.0_101
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
安装tomcat
tar -xvf apache-tomcat-7.0.72.tar.gz
tomcat自动启动
vi /etc/init.d/tomcat
#!/bin/sh
# chkconfig: 345 99 10
# description: Auto-starts tomcat
# /etc/init.d/tomcatd
# Tomcat auto-start
# Source function library.
#. /etc/init.d/functions
# source networking configuration.
#. /etc/sysconfig/network
RETVAL=0
export JAVA_HOME=/usr/local/soft/jdk1.8.0_101
export JRE_HOME=/usr/local/soft/jdk1.8.0_101/jre
export CATALINA_HOME=/home/app/tomcat-7
export CATALINA_BASE=/home/app/tomcat-7
start()
{
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
$CATALINA_HOME/bin/startup.sh
RETVAL=$?
echo " OK"
return $RETVAL
fi
}
stop()
{
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
$CATALINA_HOME/bin/shutdown.sh
RETVAL=$?
sleep 1
ps -fwwu root | grep tomcat|grep -v grep | grep -v PID | awk '{print $2}'|xargs kill -9
echo " OK"
# [ $RETVAL -eq 0 ] && rm -f /var/lock/...
return $RETVAL
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
echo $"Restaring Tomcat"
$0 stop
sleep 1
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
chmod +x /etc/init.d/tomcat
ln -s /etc/init.d/tomcat /etc/rc2.d/S16Tomcat
chkconfig --add tomcat