1.安装tomcat
1.1.解压tomcat
tar -zxvf apache-tomcat-7.0.79.tar.gz -C /app #/app是解压的位置
1.2.修改tomcat的名称
mv /app/apache-tomcat-7.0.79 /app/tomcat7
2.设置自动启动
2.1.进入系统目录
cd /etc/init.d/
2.2.创建名为tomcat的文件
vi tomcat
2.3.为tomcat文件添加命令
(注意下面括号部分的内容)
#!/bin/bash
#
# starguo guoxin_jy@126.com
# /etc/rc.d/init.d/tomcat
# init script for tomcat precesses
#
# processname: tomcat
# description: tomcat is a j2se server
# chkconfig: 2345 86 16
# description: Start up the Tomcat servlet engine.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
else
echo -e "\atomcat: unable to locate functions lib. Cannot continue."
exit -1
fi
RETVAL=$?
CATALINA_HOME="/app/tomcat7" ("/app/tomcat7" 为你的tomcat解压的目录)
case "$1" in
start)
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
$CATALINA_HOME/bin/startup.sh
fi
;;
stop)
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
$CATALINA_HOME/bin/shutdown.sh
fi
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac
exit $RETVAL
2.4.添加可执行权限
chmod 755 tomcat
2.5.指定为系统服务
chkconfig --add tomcat
2.6.修改tomcat目录下面的 bin/catalina.sh文件
(添加以下内容)
export JAVA_HOME=/app/jdk7 (idk的解压目录)
export CATALINA_HOME=/app/tomcat7 (tomcat的解压目录)
export CATALINA_BASE=/app/tomcat7
export CATALINA_TMPDIR=/app/tomcat7/temp