1、在/usr/share/tomcat6/bin中有commons-daemon-native.tar.gz 压缩包
2、解压commons-daemon-native.tar.gz
# tar -zxvf commons-daemon-native.tar.gz
3、解压完成,出现commons-daemon-1.0.2-native-src文件夹(目录)
4、 执行configure 文件
cd commons-daemon-1.0.2-native-src/unix
./configure
5、 编译
[root@localhost ~]# make #会报错
[root@localhost ~]# make clean
[root@localhost ~]# make #重新编译成功
6、 编译完成后出现jsvc文件夹,复制jsvc到/usr/share/tomcat6/bin目录下面
[root@localhost ~]# cp jsvc ../../
10、在/etc/init.d/目录下编写tomcat6启动服务配置文件。
[root@localhost ~]#cd /etc/init.d/
[root@localhost ~]# vi tomcat6
#!/bin/sh
# tomcat: Start/Stop/Restart tomcat
#
# chkconfig: 2345 85 15
# description: Apache tomcat6
# Small shell script to show how to start/stop Tomcat using jsvc
Java_HOME=/usr/java/jdk1.6.0 #根据自己的实际jdk位置来修改
CATALINA_HOME=/usr/local/tomcat #根据自己实际tomcat位置来修改
DAEMON_HOME=$CATALINA_HOME/bin
# I did not use the user.
TOMCAT_USER=tomcat
# for multi instances adapt those lines.
TMP_DIR=$CATALINA_HOME/tmp
PID_FILE=$DAEMON_HOME/jsvc.pid
CATALINA_BASE=$CATALINA_HOME
. /etc/rc.d/init.d/functions
CATALINA_OPTS=
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar
start() {
echo -n $"Starting Tomcat6: "
# If you want to specify a user to run Tomcat.
#increase the 'user $ TOMCAT_USER \' to the parameter list.
$DAEMON_HOME/jsvc \
-home $JAVA_HOME \
-Dcatalina.home=$CATALINA_HOME \
-Dcatalina.base=$CATALINA_BASE \
-Djava.io.tmpdir=$TMP_DIR \
-wait 10 \
-pidfile $PID_FILE \
-outfile $CATALINA_HOME/logs/catalina.out \
-errfile '&1' \
$CATALINA_OPTS \
-cp $CLASSPATH \
org.apache.catalina.startup.Bootstrap
echo "*****************************[ok]"
}
stop() {
echo -n $"Stopping Tomcat6: "
#
$DAEMON_HOME/jsvc \
-stop \
-pidfile $PID_FILE \
org.apache.catalina.startup.Bootstrap
echo "*****************************[ok]"
}
status() {
ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap" | awk '{printf $1 " "}' | wc | awk '{print $2}' >/tmp/tomcat_process_count.txt
read line < /tmp/tomcat_process_count.txt
if [ $line -gt 0 ]; then
echo -n "tomcat6 ( pid "
ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap" | awk '{printf $1 " "}'
echo ") is running "
else
echo "Tomcat6 is stopped"
fi
}
case "$1" in
start)
# Start Tomcat
start
exit $?
;;
stop)
# Stop Tomcat
stop
exit $?
;;
restart)
# Restart Tomcat
stop
sleep 3
start
exit $?
;;
status)
status
exit $?
;;
*)
echo "Usage: tomcat6 {start|stop|restart|status}"
exit 1;;
esac
#####
####