1、下载tomcat(apache-tomcat-5.5.17.tar.gz),解压缩到相应目录,我们这里指定/usr/local
2、添加环境变量:(添加到/etc/profile中)
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
export CLASSPATH=.:$JAVA_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin
export CATALINA_HOME=/usr/local/tomcat
3、建议单建一个用户tomcat,将其设成/opt/tomcat以下所有目录文件的属主,并由它启动tomcat:
# useradd tomcat
# chown -R tomcat:tomcat /opt/tomcat
# su - tomcat -c "/opt/tomcat/bin/startup.sh"
比较easy!
另外协议个开机自启的脚本。
#!/bin/bash # # tomcat # # chkconfig: # description: Start up the Tomcat servlet engine.
# Source function library. #. /etc/init.d/functions
RETVAL=$? CATALINA_HOME="/usr/local/tomcat/" JAVA_HOME="/usr/lib/j2sdk1.5-sun"
JAVA_OPTS="-Djava.awt.headless=true"
export JAVA_HOME export JAVA_OPTS case "$1" in start) if [ -f $CATALINA_HOME/bin/startup.sh ]; then echo $"Starting Tomcat" #/bin/su tomcat $CATALINA_HOME/bin/startup.sh $CATALINA_HOME/bin/startup.sh fi ;; stop) if [ -f $CATALINA_HOME/bin/shutdown.sh ]; then echo $"Stopping Tomcat" #/bin/su tomcat $CATALINA_HOME/bin/shutdown.sh $CATALINA_HOME/bin/shutdown.sh
fi ;; *) echo $"Usage: $0 {start|stop}" exit 1 ;; esac
exit $RETVAL |
放在/etc/init.d目录下面,再在/etc/rc$(runlevel).d目录下做个链接
ln -s ../init.d/tomcat S100tomcat
阅读(1206) | 评论(0) | 转发(1) |