iLeichun

当前位置: 首页 > Linux

Linux下Tomcat开机自动启动

分类:Linux   来源:网络   时间:2010-11-20 15:17:20

1、向/etc/profile中加入环境变量,内容如下:
JAVA_HOME=/usr/java/jdk1.5.0_09
export JAVA_HOME

JRE_HOME=/usr/java/jdk1.5.0_09/jre
export JRE_HOME

#APACHE_HOME=/usr/local/apache
#APACHE2_HOME=/usr/local/apache

TOMCAT_HOME=/usr/share/tomcat5
CATALINA_BASE=/usr/share/tomcat5
CATALINA_HOME=/usr/share/tomcat5
export TOMCAT_HOME CATALINA_BASE CATALINA_HOME

#ANT_HOME=/usr/local/apache-ant
#export ANT_HOME

#JAMES_HOME=/usr/local/james
#export JAMES_HOME

CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$TOMCAT_HOME/webapps

#CLASSPATH=$CLASSPATH:/var/www/html/webapps/WEB-INF/lib:/var/www/html/webapps/WEB-INF/classes

export CLASSPATH

#MYSQL_HOME=/usr/local/mysql

PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export PATH
2、创建Tomcat启动Shell脚本/usr/share/tomcat5/bin/tomcatd.sh,内容如下:
JAVA_HOME=/usr/java/jdk1.5.0_09
export JAVA_HOME


JRE_HOME=/usr/java/jdk1.5.0_09/jre
export JRE_HOME

#APACHE_HOME=/usr/local/apache
#APACHE2_HOME=/usr/local/apache

TOMCAT_HOME=/usr/share/tomcat5
CATALINA_BASE=/usr/share/tomcat5
CATALINA_HOME=/usr/share/tomcat5
export TOMCAT_HOME CATALINA_BASE CATALINA_HOME

#ANT_HOME=/usr/local/apache-ant
#export ANT_HOME

#JAMES_HOME=/usr/local/james
#export JAMES_HOME

CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$TOMCAT_HOME/webapps

#CLASSPATH=$CLASSPATH:/var/www/html/webapps/WEB-INF/lib:/var/www/html/webapps/WEB-INF/classes

export CLASSPATH

#MYSQL_HOME=/usr/local/mysql

PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export PATH
cd $TOMCAT_HOME/bin; ./startup.sh
3、添加启动项到/etc/rc.local中。
/usr/share/tomcat5/bin/tomcatd.sh > /dev/null &

 

更多